code: public synchronized byte[] toByteArray() {
       byte[] outBuff = new byte[count];
       int pos = 0;
  
       for (BufferPool.Buffer b: buffers) {
         System.arraycopy(b.buf, 0, outBuff, pos, b.pos);
         pos += b.pos;
       }
  
       return outBuff;
    }
docs: Creates a newly allocated byte array. Its size is the current
  size of this output stream and the valid contents of the buffer
  have been copied into it.
  
  @return  the current contents of this output stream, as a byte array.
  @see     java.io.ByteArrayOutputStream#size()