public static int networkByteOrderToInt ( byte [ ] buf , int start , int count ) { if ( count > 4 ) { throw new IllegalArgumentException ( "Cannot handle more than 4 bytes" ) ; } int result = 0 ; for ( int i = 0 ; i < count ; i ++ ) { result <<= 8 ; result |= ( buf [ start + i ] & 0xff ) ; } return result ; }
Returns the integer represented by up to 4 bytes in network byte order .