Here you can find the source of ipToLong(InetAddress ip)
public static long ipToLong(InetAddress ip)
//package com.java2s; import java.net.InetAddress; public class Main { public static long ipToLong(InetAddress ip) { byte[] octets = ip.getAddress(); long result = 0; for (byte octet : octets) { result <<= 8;//from w w w .j av a2 s .co m result |= octet & 0xff; } return result; } }