ByteUtils { public static byte[] clone(@Nullable byte[] input) { if (input == null) { return null; } byte[] ret = new byte[input.length]; System.arraycopy(input, 0, ret, 0, input.length); return ret; }  static byte[] clone(@Nullable byte[] input); static byte[] concatenate(byte[] x, byte[] y); static byte[] concatenate(byte x, byte[] y); static byte[] concatenate(byte[] x, byte y); static byte[] concatenate(byte x, byte y); static byte[] cutLeadingNullBytes(byte[] input); static byte[] cutLeadingNullByte(byte[] input); static byte[] copy(byte[] input, int offset, int length); static boolean compare(byte[] x, byte[] y); static boolean compare(byte x, byte[] y); static boolean compare(byte[] x, byte y); static boolean compare(byte x, byte y); static boolean isPrefix(byte[] prefix, byte[] data); static boolean isPrefix(byte prefix, byte[] data); static byte[] reverse(byte[] in); static String toHexString(@Nullable byte[] bytes); static String toHexString(@Nullable byte[] bytes, boolean formatted); static String toHexString(@Nullable byte[] bytes, boolean formatted, boolean addLinebreak); static String toFileSafeBase64String(@Nullable byte[] bytes); static String toWebSafeBase64String(@Nullable byte[] bytes); static String toFileSafeBase64String(@Nullable byte[] bytes, boolean withPadding); static short toShort(byte[] bytes); static short toShort(byte[] bytes, boolean bigEndian); static int toInteger(byte[] bytes); static int toInteger(byte[] bytes, boolean bigEndian); static long toLong(byte[] bytes); static long toLong(byte[] bytes, boolean bigEndian); static boolean isBitSet(int position, byte[] array); static void setBit(int position, byte[] array);  }
@Test public void testClone() { byte[] input = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 }; byte[] clone = ByteUtils.clone(input); assertFalse(clone == input); assertEquals(clone, input); assertNull(ByteUtils.clone(null)); }