Here you can find the source of ipToLong(String sip)
public static long ipToLong(String sip)
//package com.java2s; //License from project: Apache License public class Main { public static long ipToLong(String sip) { long[] ip = new long[4]; int[] pos = new int[3]; pos[0] = sip.indexOf("."); ip[0] = Long.parseLong(sip.substring(0, pos[0])); for (int i = 1; i < 3; i++) { pos[i] = sip.indexOf(".", pos[i - 1] + 1); ip[i] = Long.parseLong(sip.substring(pos[i - 1] + 1, pos[i])); if (i == 2) { ip[i + 1] = Long.parseLong(sip.substring(pos[i] + 1)); }/*from w w w . jav a2s.c om*/ } return (ip[0] << 24) + (ip[1] << 16) + (ip[2] << 8) + ip[3]; } }