ByteRead { public static int getInt(byte[] src, int startIndex) { Check.EnsureIndex(src, startIndex, 4); int value1 = (getShort(src, startIndex) & MASK_SHORT) << 16; int value2 = (getShort(src, startIndex + 2) & MASK_SHORT); return 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 testInt() { final int TEST_CASE = 164214632; ByteBuffer buffer = ByteBuffer.allocate(4); buffer = buffer.order(ByteOrder.BIG_ENDIAN); buffer.putInt(TEST_CASE); int readInt = ByteRead.getInt(buffer.array(), 0); Assert.assertEquals(TEST_CASE, readInt); }