@Test public void concat() { byte[] b1 = "a".getBytes(); byte[] b2 = "b".getBytes(); byte[] expected = "ab".getBytes(); assertArrayEquals(expected, ByteUtils.concat(b1, b2)); }
public static byte[] concat(byte[]... arrays) { int count = 0; for (byte[] array : arrays) { count += array.length; } byte[] mergedArray = new byte[count]; int start = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, mergedArray, start, array.length); start += array.length; } return mergedArray; }
ByteUtils { public static byte[] concat(byte[]... arrays) { int count = 0; for (byte[] array : arrays) { count += array.length; } byte[] mergedArray = new byte[count]; int start = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, mergedArray, start, array.length); start += array.length; } return mergedArray; } }
ByteUtils { public static byte[] concat(byte[]... arrays) { int count = 0; for (byte[] array : arrays) { count += array.length; } byte[] mergedArray = new byte[count]; int start = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, mergedArray, start, array.length); start += array.length; } return mergedArray; } private  ByteUtils(); }
ByteUtils { public static byte[] concat(byte[]... arrays) { int count = 0; for (byte[] array : arrays) { count += array.length; } byte[] mergedArray = new byte[count]; int start = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, mergedArray, start, array.length); start += array.length; } return mergedArray; } private  ByteUtils(); static byte[] prependZeros(byte[] arr, int size); static byte[] concat(byte[]... arrays); }
ByteUtils { public static byte[] concat(byte[]... arrays) { int count = 0; for (byte[] array : arrays) { count += array.length; } byte[] mergedArray = new byte[count]; int start = 0; for (byte[] array : arrays) { System.arraycopy(array, 0, mergedArray, start, array.length); start += array.length; } return mergedArray; } private  ByteUtils(); static byte[] prependZeros(byte[] arr, int size); static byte[] concat(byte[]... arrays);  }