Here you can find the source of ip2Long(String ipaddress)
public static long ip2Long(String ipaddress)
//package com.java2s; public class Main { public static long ip2Long(String ipaddress) { long[] ip = new long[4]; int position1 = ipaddress.indexOf("."); int position2 = ipaddress.indexOf(".", position1 + 1); int position3 = ipaddress.indexOf(".", position2 + 1); ip[0] = Long.parseLong(ipaddress.substring(0, position1)); ip[1] = Long.parseLong(ipaddress.substring(position1 + 1, position2)); ip[2] = Long.parseLong(ipaddress.substring(position2 + 1, position3)); ip[3] = Long.parseLong(ipaddress.substring(position3 + 1)); return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + ip[3]; }// ww w . ja v a 2s. c om }