in activeio-core/src/main/java/org/apache/activeio/packet/ByteBufferPacket.java [55:74]
public void writeTo(OutputStream out) throws IOException {
if( buffer.hasArray() ) {
// If the buffer is backed by an array.. then use it directly.
out.write(buffer.array(), position(), remaining());
position(limit());
} else {
// It's not backed by a buffer.. We can only dump it to a OutputStream via a byte[] so,
// create a temp buffer that we can use to chunk it out.
byte temp[] = new byte[TEMP_BUFFER_SIZE];
while( buffer.hasRemaining() ) {
int maxWrite = buffer.remaining() > temp.length ? temp.length : buffer.remaining();
buffer.get(temp, 0, maxWrite);
out.write(temp,0, maxWrite);
}
}
}