question: public byte [ ] toByteArray ( ) { byte [ ] bytes = new byte [ this . byteLength ] ; int offset = 0 ; for ( byte [ ] chunk : arrays ) { System . arraycopy ( chunk , 0 , bytes , offset , chunk . length ) ; offset += chunk . length ; } return bytes ; }
target:  Expensive operation of allocating a byte array to hold the entire contents of this output and then copying each underlying byte array into this new byte array.  Lots of memory copying...