code: public void write(ByteBuffer buffer) {
      if (buffer.remaining() < 8196) {
        write(buffer.array(), buffer.arrayOffset() + buffer.position(),
            buffer.remaining());
      } else { // append w/o copying bytes
        ByteBuffer dup = buffer.duplicate();
        dup.position(buffer.limit()); // ready for flip
        buffers.add(dup);
      }
    }
docs: Add a buffer to the output without copying, if possible.