I have a situation where in I keep reading with a ByteBuffer as below.
ByteBuffer buffer = MappedByteBuffer.allocateDirect(Constants.BUFFER_SIZE);
But when the reading reaches the boundary (when the remaining bytes to read is less than BUFFER_SIZE) I need to read only the boundaryLimit - FileChannel's current position
.
Means the boundary limit is x and current positions is y, then I need to read bytes from y
till x
and not beyond that.
How do I achieve this ?
I dont want to create another instance with new capacity.