Here you can find the source of concatAll(byte[] a, byte[]... rest)
public static byte[] concatAll(byte[] a, byte[]... rest)
//package com.java2s; /**//from ww w .j a va 2 s. co m * Copyright (c) 2010-2018 by the respective copyright holders. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ import java.util.Arrays; public class Main { public static byte[] concatAll(byte[] a, byte[]... rest) { int totalLength = a.length; for (byte[] b : rest) { totalLength += b.length; } byte[] result = Arrays.copyOf(a, totalLength); int offset = a.length; for (byte[] array : rest) { System.arraycopy(array, 0, result, offset, array.length); offset += array.length; } return result; } }