public static short toShort ( byte [ ] bytes , int offset , final int length ) { if ( length != SIZEOF_SHORT || offset + length > bytes . length ) { throw explainWrongLengthOrOffset ( bytes , offset , length , SIZEOF_SHORT ) ; } short n = 0 ; n ^= bytes [ offset ] & 0xFF ; n <<= 8 ; n ^= bytes [ offset + 1 ] & 0xFF ; return n ; }
Converts a byte array to a short value .