@Test public void prependZeros() { byte[] bytes = new byte[2]; bytes[0] = 'a'; bytes[1] = 'b'; byte[] expected = new byte[8]; expected[6] = 'a'; expected[7] = 'b'; assertArrayEquals(expected, ByteUtils.prependZeros(bytes, 8)); }
public static byte[] prependZeros(byte[] arr, int size) { if (arr.length > size) { throw new IllegalArgumentException("Size cannot be bigger than array size!"); } byte[] bytes = new byte[size]; System.arraycopy(arr, 0, bytes, (bytes.length - arr.length), arr.length); return bytes; }
ByteUtils { public static byte[] prependZeros(byte[] arr, int size) { if (arr.length > size) { throw new IllegalArgumentException("Size cannot be bigger than array size!"); } byte[] bytes = new byte[size]; System.arraycopy(arr, 0, bytes, (bytes.length - arr.length), arr.length); return bytes; } }
ByteUtils { public static byte[] prependZeros(byte[] arr, int size) { if (arr.length > size) { throw new IllegalArgumentException("Size cannot be bigger than array size!"); } byte[] bytes = new byte[size]; System.arraycopy(arr, 0, bytes, (bytes.length - arr.length), arr.length); return bytes; } private  ByteUtils(); }
ByteUtils { public static byte[] prependZeros(byte[] arr, int size) { if (arr.length > size) { throw new IllegalArgumentException("Size cannot be bigger than array size!"); } byte[] bytes = new byte[size]; System.arraycopy(arr, 0, bytes, (bytes.length - arr.length), arr.length); return bytes; } private  ByteUtils(); static byte[] prependZeros(byte[] arr, int size); static byte[] concat(byte[]... arrays); }
ByteUtils { public static byte[] prependZeros(byte[] arr, int size) { if (arr.length > size) { throw new IllegalArgumentException("Size cannot be bigger than array size!"); } byte[] bytes = new byte[size]; System.arraycopy(arr, 0, bytes, (bytes.length - arr.length), arr.length); return bytes; } private  ByteUtils(); static byte[] prependZeros(byte[] arr, int size); static byte[] concat(byte[]... arrays);  }