public static byte[] combine(final List<byte[]> dataChunks){
  int totalSize=0;
  for (  final byte[] dataPart : dataChunks) {
    totalSize+=dataPart.length;
  }
  final byte[] data=new byte[totalSize];
  int index=0;
  for (  final byte[] dataPart : dataChunks) {
    System.arraycopy(dataPart,0,data,index,dataPart.length);
    index+=dataPart.length;
  }
  return data;
}

public static byte [ ] combine ( final List < byte [ ] > dataChunks ) { int totalSize = 0 ; for ( final byte [ ] dataPart : dataChunks ) { totalSize += dataPart . length ; } final byte [ ] data = new byte [ totalSize ] ; int index = 0 ; for ( final byte [ ] dataPart : dataChunks ) { System . arraycopy ( dataPart , 0 , data , index , dataPart . length ) ; index += dataPart . length ; } return data ; }
combines a list of byte arrays into one big byte array .
