CodecUtils { public static byte[] intToBytes(int num) { byte[] result = new byte[4]; result[0] = (byte) (num >>> 24); result[1] = (byte) (num >>> 16); result[2] = (byte) (num >>> 8); result[3] = (byte) (num); return result; }  static byte[] intToBytes(int num); static int bytesToInt(byte[] ary); static byte[] short2bytes(short num); static byte[] copyOf(byte[] src, int length); static byte[] parseHigh4Low4Bytes(byte b); static byte buildHigh4Low4Bytes(byte high4, byte low4); static byte[] parseHigh2Low6Bytes(byte b); static byte buildHigh2Low6Bytes(byte high2, byte low6); static String byteToBits(byte b); static byte bitsToByte(String bits); static boolean startsWith(byte[] bs, byte[] head); static boolean[] byte2Booleans(byte b); static byte booleansToByte(boolean[] array); static String byte2hex(byte[] bytes); static byte[] hex2byte(String str); static boolean getBooleanFromByte(byte modifiers, int i); static byte setBooleanToByte(byte modifiers, int i, boolean bool); static void flatCopyTo(String prefix, Map<String, Object> sourceMap,
                                  Map<String, String> dstMap); static void treeCopyTo(String prefix, Map<String, String> sourceMap,
                                  Map<String, String> dstMap, boolean remove); static final Object[] EMPTY_OBJECT_ARRAY; static final Class<?>[] EMPTY_CLASS_ARRAY; }
@Test public void intToBytes() { int i = 1000; byte[] bs = CodecUtils.intToBytes(i); Assert.assertArrayEquals(bs, new byte[] { 0, 0, 3, -24 }); i = 0; bs = CodecUtils.intToBytes(i); Assert.assertArrayEquals(bs, new byte[] { 0, 0, 0, 0 }); int s = 16777218; bs = CodecUtils.intToBytes(s); Assert.assertEquals(bs[0], 1); Assert.assertEquals(bs[1], 0); Assert.assertEquals(bs[2], 0); Assert.assertEquals(bs[3], 2); }