code: public void writeTo(ByteBuffer out)
    {
      checkOpen();
      for (int i = 0; i <= headBufferIndex; i++) {
        ByteBuffer buffer = buffers.get(i);
        buffer.flip();
        out.put(buffer);
        // switch back to the initial state
        buffer.limit(buffer.capacity());
      }
    }
docs: Takes all bytes that are written to this WriteOutBytes so far and writes them into the given ByteBuffer. This method
  changes the position of the out buffer by the {@link #size()} of this WriteOutBytes.
  
  @throws java.nio.BufferOverflowException if the {@link ByteBuffer#remaining()} capacity of the given buffer is
  smaller than the size of this WriteOutBytes