@Test public void testReverseArray() { assertThat(reverseArray(new byte[]{0x01, 0x02, 0x03}), is(new byte[]{0x03, 0x02, 0x01})); assertThat(reverseArray(new byte[]{0x01, 0x02}), is(new byte[]{0x02, 0x01})); assertThat(reverseArray(new byte[]{0x01}), is(new byte[]{0x01})); assertThat(reverseArray(new byte[]{}), is(new byte[]{})); }
public static byte[] reverseArray(byte[] array) { byte[] copy = new byte[array.length]; System.arraycopy(array, 0, copy, 0, array.length); for (int i = 0; i < copy.length / 2; i++) { byte temp = copy[i]; copy[i] = copy[copy.length - i - 1]; copy[copy.length - i - 1] = temp; } return copy; }
ArrayUtils { public static byte[] reverseArray(byte[] array) { byte[] copy = new byte[array.length]; System.arraycopy(array, 0, copy, 0, array.length); for (int i = 0; i < copy.length / 2; i++) { byte temp = copy[i]; copy[i] = copy[copy.length - i - 1]; copy[copy.length - i - 1] = temp; } return copy; } }
ArrayUtils { public static byte[] reverseArray(byte[] array) { byte[] copy = new byte[array.length]; System.arraycopy(array, 0, copy, 0, array.length); for (int i = 0; i < copy.length / 2; i++) { byte temp = copy[i]; copy[i] = copy[copy.length - i - 1]; copy[copy.length - i - 1] = temp; } return copy; }  }
ArrayUtils { public static byte[] reverseArray(byte[] array) { byte[] copy = new byte[array.length]; System.arraycopy(array, 0, copy, 0, array.length); for (int i = 0; i < copy.length / 2; i++) { byte temp = copy[i]; copy[i] = copy[copy.length - i - 1]; copy[copy.length - i - 1] = temp; } return copy; }  static byte[] reverseArray(byte[] array); static byte[] concatenate(byte[] a, byte b); static byte[] concatenate(byte a, byte[] b); static byte[] concatenate(byte[]... arrays); static byte[] concatenate(byte[] a, byte[] b); static byte[] getFirstNBytes(byte[] array, int nBytes); static byte[] getLastNBytes(byte[] array, int nBytes); static byte[] xor(byte[] array1, byte[] array2); static byte[] trimLeadingBytes(byte[] bytes, byte b); static byte[] trimLeadingZeroes(byte[] bytes); static byte[] trimTrailingBytes(byte[] bytes, byte b); static byte[] toPrimitive(final Byte[] array); static byte[] toByteArray(int v); static byte[] toByteArray(long v); }
ArrayUtils { public static byte[] reverseArray(byte[] array) { byte[] copy = new byte[array.length]; System.arraycopy(array, 0, copy, 0, array.length); for (int i = 0; i < copy.length / 2; i++) { byte temp = copy[i]; copy[i] = copy[copy.length - i - 1]; copy[copy.length - i - 1] = temp; } return copy; }  static byte[] reverseArray(byte[] array); static byte[] concatenate(byte[] a, byte b); static byte[] concatenate(byte a, byte[] b); static byte[] concatenate(byte[]... arrays); static byte[] concatenate(byte[] a, byte[] b); static byte[] getFirstNBytes(byte[] array, int nBytes); static byte[] getLastNBytes(byte[] array, int nBytes); static byte[] xor(byte[] array1, byte[] array2); static byte[] trimLeadingBytes(byte[] bytes, byte b); static byte[] trimLeadingZeroes(byte[] bytes); static byte[] trimTrailingBytes(byte[] bytes, byte b); static byte[] toPrimitive(final Byte[] array); static byte[] toByteArray(int v); static byte[] toByteArray(long v);  }