Here you can find the source of concatAll(byte[] first, byte[]... rest)
public static byte[] concatAll(byte[] first, byte[]... rest)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static byte[] concatAll(byte[] first, byte[]... rest) { int totalLength = (first == null) ? 0 : first.length; for (byte[] array : rest) { totalLength += (array == null) ? 0 : array.length; }/*from w ww . j av a 2 s . c o m*/ byte[] result = (first == null) ? null : Arrays.copyOf(first, totalLength); int offset = (first == null) ? 0 : first.length; for (byte[] array : rest) { if (array != null) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } } return result; } public static int[] concatAll(int[] first, int[]... rest) { int totalLength = (first == null) ? 0 : first.length; for (int[] array : rest) { totalLength += (array == null) ? 0 : array.length; } int[] result = (first == null) ? null : Arrays.copyOf(first, totalLength); int offset = (first == null) ? 0 : first.length; for (int[] array : rest) { if (array != null) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } } return result; } public static long[] concatAll(long[] first, long[]... rest) { int totalLength = (first == null) ? 0 : first.length; for (long[] array : rest) { totalLength += (array == null) ? 0 : array.length; } long[] result = (first == null) ? null : Arrays.copyOf(first, totalLength); int offset = (first == null) ? 0 : first.length; for (long[] array : rest) { if (array != null) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } } return result; } @SafeVarargs public static <T> T[] concatAll(T[] first, T[]... rest) { int totalLength = (first == null) ? 0 : first.length; for (T[] array : rest) { totalLength += (array == null) ? 0 : array.length; } T[] result = (first == null) ? null : Arrays.copyOf(first, totalLength); int offset = (first == null) ? null : first.length; for (T[] array : rest) { if (array != null) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } } return result; } }