question: public static long ipToLong ( Inet4Address ip ) { byte [ ] octets = ip . getAddress ( ) ; long result = 0 ; for ( byte octet : octets ) { result <<= 8 ; result |= octet & 0xff ; } return result ; }
target:  Convert an Inet4Address to host byte order long.