/** Add a buffer to the output without copying, if possible. */ public void writeBuffer(ByteBuffer buffer) throws IOException { if (buffer.remaining() < BUFFER_SIZE) { write(buffer.array(), buffer.position(), buffer.remaining()); } else { // append w/o copying bytes ByteBuffer dup = buffer.duplicate(); dup.position(buffer.limit()); // ready for flip buffers.add(dup); } } }
/** Add a buffer to the output without copying, if possible. */ public void writeBuffer(ByteBuffer buffer) throws IOException { if (buffer.remaining() < BUFFER_SIZE) { write(buffer.array(), buffer.position(), buffer.remaining()); } else { // append w/o copying bytes ByteBuffer dup = buffer.duplicate(); dup.position(buffer.limit()); // ready for flip buffers.add(dup); } } }
/** Add a buffer to the output without copying, if possible. */ public void writeBuffer(ByteBuffer buffer) throws IOException { if (buffer.remaining() < BUFFER_SIZE) { write(buffer.array(), buffer.position(), buffer.remaining()); } else { // append w/o copying bytes ByteBuffer dup = buffer.duplicate(); dup.position(buffer.limit()); // ready for flip buffers.add(dup); } } }
/** Add a buffer to the output without copying, if possible. */ public void writeBuffer(ByteBuffer buffer) throws IOException { if (buffer.remaining() < BUFFER_SIZE) { write(buffer.array(), buffer.position(), buffer.remaining()); } else { // append w/o copying bytes ByteBuffer dup = buffer.duplicate(); dup.position(buffer.limit()); // ready for flip buffers.add(dup); } } }