code: public long convertIPString(String ip) throws NumberFormatException, 
      IllegalArgumentException {
  
          StringTokenizer st = new StringTokenizer(ip,".");
          if (st.countTokens() == 4) {
              long ipLong = (Long.parseLong(st.nextToken()) << 24);
              ipLong += (Long.parseLong(st.nextToken()) << 16);
              ipLong += (Long.parseLong(st.nextToken()) << 8);
              ipLong += Long.parseLong(st.nextToken());
              return ipLong;
          }
          else {
              throw new IllegalArgumentException("Invalid IP string");
          }
      }
docs: turns a dot delimited IP address string into a long.