Here you can find the source of merge(final byte[]... data)
public static byte[] merge(final byte[]... data)
//package com.java2s; // it under the terms of the GNU General Public License as published by public class Main { public static byte[] merge(final byte[]... data) { int size = 0; for (final byte[] a : data) size += a.length;/* ww w . jav a2 s.c om*/ final byte[] r = new byte[size]; for (final byte[] a : data) combine(r, a); return r; } public static byte[] combine(final byte[] array1, final byte[] array2) { if (array1 == null) return copy(array2); else if (array2 == null) return copy(array1); final byte[] joinedArray = new byte[array1.length + array2.length]; System.arraycopy(array1, 0, joinedArray, 0, array1.length); System.arraycopy(array2, 0, joinedArray, array1.length, array2.length); return joinedArray; } public static byte[] copy(final byte[] array) { if (array == null) return null; return array.clone(); } }