Java tutorial
//package com.java2s; /* of theGNU Lesser General Public License ("LGPL") as published as of */ public class Main { /** * Concatenates two byte arrays into one new byte array * * @param source1 the first byte array (will be at the beginning of the new array) * @param source2 the second byte array (will be at the end of the new array) * @return the concatenation of the two arrays * @throws ArrayIndexOutOfBoundsException if the value of <code>index</code> causes an illegal array access. */ public static byte[] concatenate(final byte[] source1, final byte[] source2) { byte[] result = new byte[source1.length + source2.length]; System.arraycopy(source1, 0, result, 0, source1.length); System.arraycopy(source2, 0, result, source1.length, source2.length); return result; } }