public static long ipToLong(String address){
  if (address == null)   return 0L;
  String[] quads=address.split("\\.");
  long result=0;
  if (quads.length != 4)   return 0L;
  try {
    result+=Integer.parseInt(quads[3]);
    result+=Long.parseLong(quads[2]) << 8L;
    result+=Long.parseLong(quads[1]) << 16L;
    result+=Long.parseLong(quads[0]) << 24L;
  }
 catch (  Exception ex) {
    return result;
  }
  return result;
}

public static long ipToLong ( String address ) { if ( address == null ) return 0L ; String [ ] quads = address . split ( "\\." ) ; long result = 0 ; if ( quads . length != 4 ) return 0L ; try { result += Integer . parseInt ( quads [ 3 ] ) ; result += Long . parseLong ( quads [ 2 ] ) << 8L ; result += Long . parseLong ( quads [ 1 ] ) << 16L ; result += Long . parseLong ( quads [ 0 ] ) << 24L ; } catch ( Exception ex ) { return result ; } return result ; }
convert a long to an ip address
