You can use Guava library, it has Bytes which supports converting byte[] to List<Byte> and back via:
public static List<Byte> asList(byte... backingArray)
and
public static byte[] toArray(Collection<? extends Number> collection)
Another option is to simply iterate and copy the arrays, one by one, to one big byte[], it seems to me simpler and more straightforward that the code in the accepted answer...
public static void main(String[] args) {
List<byte[]> list = Arrays.asList("abc".getBytes(), "def".getBytes());
byte[] flattened= flatByteList(list);
System.out.println(new String(flattened)); // abcdef
}
private static byte[] flatByteList(List<byte[]> list) {
int byteArrlength = list.get(0).length;
byte[] result = new byte[list.size() * byteArrlength]; // since all the arrays have the same size
for (int i = 0; i < list.size(); i++) {
byte[] arr = list.get(i);
for (int j = 0; j < byteArrlength; j++) {
result[i * byteArrlength + j] = arr[j];
}
}
return result;
}