Here you can find the source of ipToLong(String strIP)
private static long ipToLong(String strIP)
//package com.java2s; //License from project: Apache License public class Main { private static long ipToLong(String strIP) { int j = 0; int i = 0; long[] ip = new long[4]; int position1 = strIP.indexOf("."); int position2 = strIP.indexOf(".", position1 + 1); int position3 = strIP.indexOf(".", position2 + 1); ip[0] = Long.parseLong(strIP.substring(0, position1)); ip[1] = Long.parseLong(strIP.substring(position1 + 1, position2)); ip[2] = Long.parseLong(strIP.substring(position2 + 1, position3)); ip[3] = Long.parseLong(strIP.substring(position3 + 1)); return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + ip[3]; }//from w ww.j a v a 2 s . co m }