private static long bytesToLong ( byte [ ] address ) { long ipnum = 0 ; for ( int i = 0 ; i < 4 ; ++ i ) { long y = address [ i ] ; if ( y < 0 ) { y += 256 ; } ipnum += y << ( ( 3 - i ) * 8 ) ; } return ipnum ; }
Returns the long version of an IP address given an InetAddress object .