public static byte [ ] concat ( final byte [ ] ... arrays ) { int len = 0 ; for ( final byte [ ] arr : arrays ) { len += arr . length ; } final byte [ ] result = new byte [ len ] ; int pos = 0 ; for ( final byte [ ] arr : arrays ) { System . arraycopy ( arr , 0 , result , pos , arr . length ) ; pos += arr . length ; } return result ; }
Concatenate byte arrays into one byte array sequentially .