public static int twoBytesToInt ( byte [ ] bytes , ByteOrder order ) { if ( order == ByteOrder . BIG_ENDIAN ) { return bytesToInt ( bytes [ 0 ] , bytes [ 1 ] ) ; } else if ( order == ByteOrder . LITTLE_ENDIAN ) { return bytesToInt ( bytes [ 1 ] , bytes [ 0 ] ) ; } else { throw new IllegalArgumentException ( "ByteOrder must be BIG_ENDIAN or LITTLE_ENDIAN" ) ; } }
Convert an array of two unsigned bytes with the given byte order to one signed int .