Here you can find the source of ip2Long(String ip)
public static long ip2Long(String ip)
//package com.java2s; public class Main { public static long ip2Long(String ip) { long ret = 0; if (ip == null) { return ret; }/*from w ww.j a v a 2s.c om*/ String[] segs = ip.split("\\."); for (int i = 0; i < segs.length; i++) { long seg = Long.parseLong(segs[i]); ret += (seg << ((3 - i) * 8)); } return ret; } }