ByteBuf.readRetainedSlice

Returns a new retained slice of this buffer's sub-region starting at the current {@code readerIndex} and increases the {@code readerIndex} by the size of the new slice (= {@code length}). <p> Note that this method returns a {@linkplain #retain() retained} buffer unlike {@link #readSlice(int)}. This method behaves similarly to {@code readSlice(...).retain()} except that this method may return a buffer implementation that produces less garbage.

@param length the size of the new slice

@return the newly created slice

@throws IndexOutOfBoundsException if {@code length} is greater than {@code this.readableBytes}

class ByteBuf
abstract
readRetainedSlice
(
int length
)

Meta