readBuffer method
Returns a ByteBuf viewing a region beginning at readerIndex
with the length of length
.
The ByteBuf.writerIndex is set to length
and
the ByteBuf.readerIndex is set to 0, making
the whole region readable via ByteBuf.readAvailableBytes.
Exceptions:
-
ReadIndexOutOfRangeException if the current reader index is outside of the bounds of the buffer.
-
BufferOverreadException if the length of the readerIndex + length is outside of the bounds of the buffer.
Implementation
ByteBuf readBuffer(int length) {
assertReadable(readerIndex, length);
try {
return viewBuffer(readerIndex, length)..writerIndex += length;
} finally {
readerIndex += length;
}
}