ByteBuf.retainedSlice

Returns a retained slice of this buffer's readable bytes. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical to {@code buf.slice(buf.readerIndex(), buf.readableBytes())}. This method does not modify {@code readerIndex} or {@code writerIndex} of this buffer. <p> Note that this method returns a {@linkplain #retain() retained} buffer unlike {@link #slice()}. This method behaves similarly to {@code slice().retain()} except that this method may return a buffer implementation that produces less garbage.

  1. ByteBuf retainedSlice()
    class ByteBuf
    abstract
    retainedSlice
    ()
  2. ByteBuf retainedSlice(int index, int length)

Meta