ByteRead { public static short getShort(byte[] src, int startIndex) { Check.EnsureIndex(src, startIndex, 2); int value1 = (src[startIndex] & MASK_BYTE) << 8; int value2 = src[startIndex + 1] & MASK_BYTE; return (short) (value1 | value2); } private  ByteRead(); static byte getByte(byte[] src, int startIndex); static boolean getBoolean(byte[] src, int startIndex); static short getUnsignedByte(byte[] src, int startIndex); static short getShort(byte[] src, int startIndex); static int getInt(byte[] src, int startIndex); static long getLong(byte[] src, int startIndex); static byte[] getBytes(byte[] src, int startIndex); static byte[] getBytes(byte[] src, int startIndex, int size);  }
@Test public void testShort() { final short TEST_CASE = (short) 62510; ByteBuffer buffer = ByteBuffer.allocate(2); buffer = buffer.order(ByteOrder.BIG_ENDIAN); buffer.putShort(TEST_CASE); short readShort = ByteRead.getShort(buffer.array(), 0); Assert.assertEquals(TEST_CASE, readShort); }