code: @Override
     protected void writeBuffer(byte[] buffer, int start, int length) throws IOException
     {
        if (out instanceof ByteArrayOutputStream)
        {
           if (((ByteArrayOutputStream)out).size() + length > bufferSize)
           {
              swapBuffers();
           }
        }
        out.write(buffer, start, length);
     }
docs: Writes <code>length</code> bytes from the specified byte array starting at offset
  <code>start</code> to this byte array output stream.
  
  @param buffer
  the data.
  @param start
  the start offset in the data.
  @param length
  the number of bytes to write.
  @exception IOException
  if an I/O error occurs.