Here you can find the source of union(List
public static byte[] union(List<byte[]> byteList)
//package com.java2s; import java.util.List; public class Main { public static byte[] union(List<byte[]> byteList) { int size = 0; for (byte[] bs : byteList) { size += bs.length;/* w w w .j av a2 s .co m*/ } byte[] ret = new byte[size]; int pos = 0; for (byte[] bs : byteList) { System.arraycopy(bs, 0, ret, pos, bs.length); pos += bs.length; } return ret; } }