Return a direct ByteBuffer
view
if (byteBuffer == null ||
(byteBuffer.capacity() - byteBuffer.limit() < size)){
if ( direct )
byteBuffer = ByteBuffer.allocateDirect(capacity);
else
byteBuffer = ByteBuffer.allocate(capacity);
}
byteBuffer.limit(byteBuffer.position() + size);
ByteBuffer view = byteBuffer.slice();
byteBuffer.position(byteBuffer.limit());
return view;