ByteUtils { public static boolean compare(byte[] x, byte[] y) { if (y == null || x == null) { return false; } if (x.length != y.length) { return false; } return Arrays.areEqual(x, y); }  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 testCompare() { byte a = 1, b = 1, c = 2; byte[] d = new byte[] { 1 }, e = new byte[] { 2 }; assertTrue(ByteUtils.compare(a, b)); assertFalse(ByteUtils.compare(a, c)); assertTrue(ByteUtils.compare(a, d)); assertFalse(ByteUtils.compare(a, e)); assertFalse(ByteUtils.compare(e, a)); }