Here you can find the source of getLongIp(byte[] buff)
public static long getLongIp(byte[] buff)
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static long getLongIp(byte[] buff) { long ip;/*from w w w .j a v a 2s.c o m*/ long workLong1, workLong2, workLong3, workLong4; workLong1 = (long) buff[0] & 0x000000FF; workLong1 = workLong1 << 24; workLong2 = (long) buff[1] & 0x000000FF; workLong2 = workLong2 << 16; workLong3 = (long) buff[2] & 0x000000FF; workLong3 = workLong3 << 8; workLong4 = (long) buff[3] & 0x000000FF; ip = workLong1 | workLong2 | workLong3 | workLong4; return ip; } public static long getLongIp(InetAddress host) { return getLongIp(host.getAddress()); } public static long getLongIp(String ip) { try { return getLongIp(InetAddress.getByName(ip)); } catch (UnknownHostException ex) { return 0; } } }