Util { public static byte[] joinBytes(byte[]... bytes) { int length = 0; for (byte[] byt : bytes) { length += byt.length; } byte[] answer = new byte[length + bytes.length * INT]; int offset = 0; for (byte[] byt : bytes) { System.arraycopy(Util.int2bin(byt.length), 0, answer, offset, INT); offset += INT; System.arraycopy(byt, 0, answer, offset, byt.length); offset += byt.length; } return answer; } private  Util(); static void int2bin(byte[] out, int offset, int i); static byte[] int2bin(int i); static void long2bin(byte[] out, int offset, long i); static byte[] long2bin(long i); static byte[] double2bin(double d); static void double2bin(byte[] out, int offset, double d); static byte[] boolean2bin(boolean b); static void boolean2bin(byte[] out, int offset, boolean b); static int bin2int(byte[] array, int offset); static long bin2long(byte[] array, int offset); static long bin2long(byte[] array); static double bin2double(byte[] array, int offset); static double bin2double(byte[] array); static boolean bin2boolean(byte[] array, int offset); static boolean bin2boolean(byte[] array); static byte[] twosComplimentToPositiveInt(byte[] input); static byte[] positiveIntToTwosCompliment(byte[] input); static BigInteger byteToBigInt(byte[] input); static byte[] bigIntToByte(BigInteger input); static byte[] joinBytes(byte[]... bytes); static List<byte[]> splitBytes(byte[] bytes); static byte[][] listByte2Array(List<byte[]> bytes); static int compareByteArrays(byte[] first, byte[] second); static void checkPassword(final String password); static void checkUsername(final String username); static boolean deleteDir(File dir); static void addFrom(Throwable t, Throwable from); static byte[] hashKey(byte[] publicKey); static final int INT; static final int LONG; static final int DOUBLE; static final int BOOLEAN; }
@Test public void joinBytes() { assertArrayEquals(thousandThousand, Util.joinBytes(thousandint, thousandlong)); }