Here you can find the source of ipToLong(String ip)
public static long ipToLong(String ip)
//package com.java2s; //License from project: Open Source License public class Main { public static long ipToLong(String ip) { // TODO: check me final String[] ipBytesStr = ip.split("\\."); long ipValue = 0; for (int i = 0; i < 4; i++) { ipValue <<= 8;// ww w .j av a 2 s .com ipValue |= Integer.parseInt(ipBytesStr[i]); } return ipValue; } }