static public int bytesToInt ( byte [ ] buffer , int index ) { int length = buffer . length - index ; if ( length > 4 ) length = 4 ; int integer = 0 ; for ( int i = 0 ; i < length ; i ++ ) { integer |= ( ( buffer [ index + length - i - 1 ] & 0xFF ) << ( i * 8 ) ) ; } return integer ; }
This function converts the bytes in a byte array at the specified index to its corresponding integer value .