Top Description Constructors Methods
io.netty.buffer

public abstract Class ByteBuf

extends Object
implements ReferenceCounted, Comparable<ByteBuf>, ByteBufConvertible
Class Inheritance
All Implemented Interfaces
io.netty.buffer.ByteBufConvertible, java.lang.Comparable, io.netty.util.ReferenceCounted
Known Direct Subclasses
io.netty.buffer.SwappedByteBuf, io.netty.buffer.WrappedByteBuf, io.netty.buffer.EmptyByteBuf, io.netty.buffer.AbstractByteBuf
Imports
io.netty.util.ByteProcessor, .ReferenceCounted, java.io.IOException, .InputStream, .OutputStream, java.nio.ByteBuffer, .ByteOrder, java.nio.channels.FileChannel, .GatheringByteChannel, .ScatteringByteChannel, java.nio.charset.Charset, .UnsupportedCharsetException

A random and sequential accessible sequence of zero or more bytes (octets). This interface provides an abstract view for one or more primitive byte arrays (byte[]) and NIO buffers.

Creation of a buffer

It is recommended to create a new buffer using the helper methods in Unpooled rather than calling an individual implementation's constructor.

Random Access Indexing

Just like an ordinary primitive byte array, ByteBuf uses zero-based indexing. It means the index of the first byte is always 0 and the index of the last byte is always capacity - 1. For example, to iterate all bytes of a buffer, you can do the following, regardless of its internal implementation:
ByteBuf buffer = ...;
for (int i = 0; i < buffer.capacity(); i ++) {
    byte b = buffer.getByte(i);
    System.out.println((char) b);
}

Sequential Access Indexing

ByteBuf provides two pointer variables to support sequential read and write operations - readerIndex for a read operation and writerIndex for a write operation respectively. The following diagram shows how a buffer is segmented into three areas by the two pointers:
     +-------------------+------------------+------------------+
     | discardable bytes |  readable bytes  |  writable bytes  |
     |                   |     (CONTENT)    |                  |
     +-------------------+------------------+------------------+
     |                   |                  |                  |
     0      <=      readerIndex   <=   writerIndex    <=    capacity

Readable bytes (the actual content)

This segment is where the actual data is stored. Any operation whose name starts with read or skip will get or skip the data at the current readerIndex and increase it by the number of read bytes. If the argument of the read operation is also a ByteBuf and no destination index is specified, the specified buffer's writerIndex is increased together.

If there's not enough content left, IndexOutOfBoundsException is raised. The default value of newly allocated, wrapped or copied buffer's readerIndex is 0.

// Iterates the readable bytes of a buffer.
ByteBuf buffer = ...;
while (buffer.isReadable()) {
    System.out.println(buffer.readByte());
}

Writable bytes

This segment is a undefined space which needs to be filled. Any operation whose name starts with write will write the data at the current writerIndex and increase it by the number of written bytes. If the argument of the write operation is also a ByteBuf, and no source index is specified, the specified buffer's readerIndex is increased together.

If there's not enough writable bytes left, IndexOutOfBoundsException is raised. The default value of newly allocated buffer's writerIndex is 0. The default value of wrapped or copied buffer's writerIndex is the capacity of the buffer.

// Fills the writable bytes of a buffer with random integers.
ByteBuf buffer = ...;
while (buffer.maxWritableBytes() >= 4) {
    buffer.writeInt(random.nextInt());
}

Discardable bytes

This segment contains the bytes which were read already by a read operation. Initially, the size of this segment is 0, but its size increases up to the writerIndex as read operations are executed. The read bytes can be discarded by calling discardReadBytes() to reclaim unused area as depicted by the following diagram:
 BEFORE discardReadBytes()

     +-------------------+------------------+------------------+
     | discardable bytes |  readable bytes  |  writable bytes  |
     +-------------------+------------------+------------------+
     |                   |                  |                  |
     0      <=      readerIndex   <=   writerIndex    <=    capacity


 AFTER discardReadBytes()

     +------------------+--------------------------------------+
     |  readable bytes  |    writable bytes (got more space)   |
     +------------------+--------------------------------------+
     |                  |                                      |
readerIndex (0) <= writerIndex (decreased)        <=        capacity
Please note that there is no guarantee about the content of writable bytes after calling discardReadBytes(). The writable bytes will not be moved in most cases and could even be filled with completely different data depending on the underlying buffer implementation.

Clearing the buffer indexes

You can set both readerIndex and writerIndex to 0 by calling clear(). It does not clear the buffer content (e.g. filling with 0) but just clears the two pointers. Please also note that the semantic of this operation is different from ByteBuffer#clear().
 BEFORE clear()

     +-------------------+------------------+------------------+
     | discardable bytes |  readable bytes  |  writable bytes  |
     +-------------------+------------------+------------------+
     |                   |                  |                  |
     0      <=      readerIndex   <=   writerIndex    <=    capacity


 AFTER clear()

     +---------------------------------------------------------+
     |             writable bytes (got more space)             |
     +---------------------------------------------------------+
     |                                                         |
     0 = readerIndex = writerIndex            <=            capacity

Search operations

For simple single-byte searches, use indexOf(int, int, byte) and bytesBefore(int, int, byte). bytesBefore(byte) is especially useful when you deal with a NUL-terminated string. For complicated searches, use forEachByte(int, int, ByteProcessor) with a ByteProcessor implementation.

Mark and reset

There are two marker indexes in every buffer. One is for storing readerIndex and the other is for storing writerIndex. You can always reposition one of the two indexes by calling a reset method. It works in a similar fashion to the mark and reset methods in InputStream except that there's no readlimit.

Derived buffers

You can create a view of an existing buffer by calling one of the following methods: A derived buffer will have an independent readerIndex, writerIndex and marker indexes, while it shares other internal data representation, just like a NIO buffer does.

In case a completely fresh copy of an existing buffer is required, please call copy() method instead.

Non-retained and retained derived buffers

Note that the duplicate(), slice(), slice(int, int) and readSlice(int) does NOT call retain() on the returned derived buffer, and thus its reference count will NOT be increased. If you need to create a derived buffer with increased reference count, consider using retainedDuplicate(), retainedSlice(), retainedSlice(int, int) and readRetainedSlice(int) which may return a buffer implementation that produces less garbage.

Conversion to existing JDK types

Byte array

If a ByteBuf is backed by a byte array (i.e. byte[]), you can access it directly via the array() method. To determine if a buffer is backed by a byte array, hasArray() should be used.

NIO Buffers

If a ByteBuf can be converted into an NIO ByteBuffer which shares its content (i.e. view buffer), you can get it via the nioBuffer() method. To determine if a buffer can be converted into an NIO buffer, use nioBufferCount().

Strings

Various toString(Charset) methods convert a ByteBuf into a String. Please note that toString() is not a conversion method.

I/O Streams

Please refer to ByteBufInputStream and ByteBufOutputStream.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public abstract ByteBufAllocator
alloc()

Returns the ByteBufAllocator which created this buffer.

public abstract byte[]
array()

Returns the backing byte array of this buffer.

public abstract int
arrayOffset()

Returns the offset of the first byte within the backing byte array of this buffer.

public ByteBuf

Returns:

This ByteBuf instance.
asByteBuf
()

Implements io.netty.buffer.ByteBufConvertible.asByteBuf.

A ByteBuf can turn into itself.
public abstract ByteBuf
asReadOnly()

Returns a read-only version of this buffer.

public abstract int

Returns:

the number of bytes between the current readerIndex and the first occurrence if found. -1 otherwise.
bytesBefore
(byte value)

Locates the first occurrence of the specified value in this buffer.

public abstract int

Returns:

the number of bytes between the current readerIndex and the first occurrence if found. -1 otherwise.
bytesBefore
(int length, byte value)

Locates the first occurrence of the specified value in this buffer.

public abstract int

Returns:

the number of bytes between the specified index and the first occurrence if found. -1 otherwise.
bytesBefore
(int index, int length, byte value)

Locates the first occurrence of the specified value in this buffer.

public abstract int
capacity()

Returns the number of bytes (octets) this buffer can contain.

public abstract ByteBuf
capacity(int newCapacity)

Adjusts the capacity of this buffer.

public abstract ByteBuf
clear()

Sets the readerIndex and writerIndex of this buffer to 0.

public abstract int
compareTo(ByteBuf
the object to be compared.
buffer
)

Redeclares java.lang.Comparable.compareTo.

Compares the content of the specified buffer to the content of this buffer.
public abstract ByteBuf
copy()

Returns a copy of this buffer's readable bytes.

public abstract ByteBuf
copy(int index, int length)

Returns a copy of this buffer's sub-region.

public abstract ByteBuf
discardReadBytes()

Discards the bytes between the 0th index and readerIndex.

public abstract ByteBuf
discardSomeReadBytes()

Similar to ByteBuf#discardReadBytes() except that this method might discard some, all, or none of read bytes depending on its internal implementation to reduce overall memory bandwidth consumption at the cost of potentially additional memory consumption.

public abstract ByteBuf

Returns:

A buffer whose readable content is equivalent to the buffer returned by slice(). However this buffer will share the capacity of the underlying buffer, and therefore allows access to all of the underlying content if necessary.
duplicate
()

Returns a buffer which shares the whole region of this buffer.

public abstract ByteBuf
ensureWritable(int
the expected minimum number of writable bytes
minWritableBytes
)

Expands the buffer capacity() to make sure the number of writable bytes is equal to or greater than the specified value.

public abstract int

Returns:

0 if the buffer has enough writable bytes, and its capacity is unchanged. 1 if the buffer does not have enough bytes, and its capacity is unchanged. 2 if the buffer has enough writable bytes, and its capacity has been increased. 3 if the buffer does not have enough bytes, but its capacity has been increased to its maximum.
ensureWritable
(int
the expected minimum number of writable bytes
minWritableBytes
,
boolean
When writerIndex() + minWritableBytes > maxCapacity():
  • true - the capacity of the buffer is expanded to maxCapacity()
  • false - the capacity of the buffer is unchanged
force
)

Expands the buffer capacity() to make sure the number of writable bytes is equal to or greater than the specified value.

public abstract boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Determines if the content of the specified buffer is identical to the content of this array.
public abstract int

Returns:

-1 if the processor iterated to or beyond the end of the readable bytes. The last-visited index If the ByteProcessor#process(byte) returned false.
forEachByte
(ByteProcessor processor)

Iterates over the readable bytes of this buffer with the specified processor in ascending order.

public abstract int

Returns:

-1 if the processor iterated to or beyond the end of the specified area. The last-visited index If the ByteProcessor#process(byte) returned false.
forEachByte
(int index, int length, ByteProcessor processor)

Iterates over the specified area of this buffer with the specified processor in ascending order.

public abstract int

Returns:

-1 if the processor iterated to or beyond the beginning of the readable bytes. The last-visited index If the ByteProcessor#process(byte) returned false.
forEachByteDesc
(ByteProcessor processor)

Iterates over the readable bytes of this buffer with the specified processor in descending order.

public abstract int

Returns:

-1 if the processor iterated to or beyond the beginning of the specified area. The last-visited index If the ByteProcessor#process(byte) returned false.
forEachByteDesc
(int index, int length, ByteProcessor processor)

Iterates over the specified area of this buffer with the specified processor in descending order.

public abstract boolean
getBoolean(int index)

Gets a boolean at the specified absolute (@code index) in this buffer.

public abstract byte
getByte(int index)

Gets a byte at the specified absolute index in this buffer.

public abstract ByteBuf
getBytes(int index, ByteBuf dst)

Transfers this buffer's data to the specified destination starting at the specified absolute index until the destination becomes non-writable.

public abstract ByteBuf
getBytes(int index, ByteBuf dst, int
the number of bytes to transfer
length
)

Transfers this buffer's data to the specified destination starting at the specified absolute index.

public abstract ByteBuf
getBytes(int index, ByteBuf dst, int
the first index of the destination
dstIndex
,
int
the number of bytes to transfer
length
)

Transfers this buffer's data to the specified destination starting at the specified absolute index.

public abstract ByteBuf
getBytes(int index, byte[] dst)

Transfers this buffer's data to the specified destination starting at the specified absolute index.

public abstract ByteBuf
getBytes(int index, byte[] dst, int
the first index of the destination
dstIndex
,
int
the number of bytes to transfer
length
)

Transfers this buffer's data to the specified destination starting at the specified absolute index.

public abstract ByteBuf
getBytes(int index, ByteBuffer dst)

Transfers this buffer's data to the specified destination starting at the specified absolute index until the destination's position reaches its limit.

public abstract ByteBuf
getBytes(int index, OutputStream out, int
the number of bytes to transfer
length
)

Transfers this buffer's data to the specified stream starting at the specified absolute index.

public abstract int

Returns:

the actual number of bytes written out to the specified channel
getBytes
(int index, GatheringByteChannel out, int
the maximum number of bytes to transfer
length
)

Transfers this buffer's data to the specified channel starting at the specified absolute index.

public abstract int

Returns:

the actual number of bytes written out to the specified channel
getBytes
(int index, FileChannel out, long
the file position at which the transfer is to begin
position
,
int
the maximum number of bytes to transfer
length
)

Transfers this buffer's data starting at the specified absolute index to the specified channel starting at the given file position.

public abstract char
getChar(int index)

Gets a 2-byte UTF-16 character at the specified absolute index in this buffer.

public abstract CharSequence

Returns:

the sequence
getCharSequence
(int index, int
the length to read
length
,
Charset
that should be used
charset
)

Gets a CharSequence with the given length at the given index.

public abstract double
getDouble(int index)

Gets a 64-bit floating point number at the specified absolute index in this buffer.

public double
getDoubleLE(int index)

Gets a 64-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract float
getFloat(int index)

Gets a 32-bit floating point number at the specified absolute index in this buffer.

public float
getFloatLE(int index)

Gets a 32-bit floating point number at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract int
getInt(int index)

Gets a 32-bit integer at the specified absolute index in this buffer.

public abstract int
getIntLE(int index)

Gets a 32-bit integer at the specified absolute index in this buffer with Little Endian Byte Order.

public abstract long
getLong(int index)

Gets a 64-bit long integer at the specified absolute index in this buffer.

public abstract long
getLongLE(int index)

Gets a 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract int
getMedium(int index)

Gets a 24-bit medium integer at the specified absolute index in this buffer.

public abstract int
getMediumLE(int index)

Gets a 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order.

public abstract short
getShort(int index)

Gets a 16-bit short integer at the specified absolute index in this buffer.

public abstract short
getShortLE(int index)

Gets a 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract short
getUnsignedByte(int index)

Gets an unsigned byte at the specified absolute index in this buffer.

public abstract long
getUnsignedInt(int index)

Gets an unsigned 32-bit integer at the specified absolute index in this buffer.

public abstract long
getUnsignedIntLE(int index)

Gets an unsigned 32-bit integer at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract int
getUnsignedMedium(int index)

Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer.

public abstract int
getUnsignedMediumLE(int index)

Gets an unsigned 24-bit medium integer at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract int
getUnsignedShort(int index)

Gets an unsigned 16-bit short integer at the specified absolute index in this buffer.

public abstract int
getUnsignedShortLE(int index)

Gets an unsigned 16-bit short integer at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract boolean
hasArray()

Returns true if and only if this buffer has a backing byte array.

public abstract int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code which was calculated from the content of this buffer.
public abstract boolean
hasMemoryAddress()

Returns true if and only if this buffer has a reference to the low-level memory address that points to the backing data.

public abstract int

Returns:

the absolute index of the first occurrence if found. -1 otherwise.
indexOf
(int fromIndex, int toIndex, byte value)

Locates the first occurrence of the specified value in this buffer.

public abstract ByteBuffer
internalNioBuffer(int index, int length)

Internal use only: Exposes the internal NIO buffer.

pack-priv boolean
isAccessible()

Used internally by AbstractByteBuf#ensureAccessible() to try to guard against using the buffer after it was released (best-effort).

public boolean
isContiguous()

Returns true if this ByteBuf implementation is backed by a single memory region.

public abstract boolean
isDirect()

Returns true if and only if this buffer is backed by an NIO direct buffer.

public abstract boolean
isReadable()

Returns true if and only if (this.writerIndex - this.readerIndex) is greater than 0.

public abstract boolean
isReadable(int size)

Returns true if and only if this buffer contains equal to or more than the specified number of elements.

public abstract boolean
isReadOnly()

Returns true if and only if this buffer is read-only.

public abstract boolean
isWritable()

Returns true if and only if (this.capacity - this.writerIndex) is greater than 0.

public abstract boolean
isWritable(int size)

Returns true if and only if this buffer has enough room to allow writing the specified number of elements.

public abstract ByteBuf
markReaderIndex()

Marks the current readerIndex in this buffer.

public abstract ByteBuf
markWriterIndex()

Marks the current writerIndex in this buffer.

public abstract int
maxCapacity()

Returns the maximum allowed capacity of this buffer.

public int
maxFastWritableBytes()

Returns the maximum number of bytes which can be written for certain without involving an internal reallocation or data-copy.

public abstract int
maxWritableBytes()

Returns the maximum possible number of writable bytes, which is equal to (this.maxCapacity - this.writerIndex).

public abstract long
memoryAddress()

Returns the low-level memory address that point to the first byte of ths backing data.

public abstract ByteBuffer
nioBuffer()

Exposes this buffer's readable bytes as an NIO ByteBuffer.

public abstract ByteBuffer
nioBuffer(int index, int length)

Exposes this buffer's sub-region as an NIO ByteBuffer.

public abstract int

Returns:

-1 if this buffer has no underlying ByteBuffer. the number of the underlying ByteBuffers if this buffer has at least one underlying ByteBuffer. Note that this method does not return 0 to avoid confusion.
nioBufferCount
()

Returns the maximum number of NIO ByteBuffers that consist this buffer.

public abstract ByteBuffer[]
nioBuffers()

Exposes this buffer's readable bytes as an NIO ByteBuffer's.

public abstract ByteBuffer[]
nioBuffers(int index, int length)

Exposes this buffer's bytes as an NIO ByteBuffer's for the specified index and length The returned buffer either share or contains the copied content of this buffer, while changing the position and limit of the returned NIO buffer does not affect the indexes and marks of this buffer.

public abstract ByteOrder
order()

Deprecated use the Little Endian accessors, e.g. getShortLE, getIntLE instead of creating a buffer with swapped endianness.
Returns the endianness of this buffer.
public abstract ByteBuf
order(ByteOrder endianness)

Deprecated use the Little Endian accessors, e.g. getShortLE, getIntLE instead of creating a buffer with swapped endianness.
Returns a buffer with the specified endianness which shares the whole region, indexes, and marks of this buffer.
public abstract int
readableBytes()

Returns the number of readable bytes which is equal to (this.writerIndex - this.readerIndex).

public abstract boolean
readBoolean()

Gets a boolean at the current readerIndex and increases the readerIndex by 1 in this buffer.

public abstract byte
readByte()

Gets a byte at the current readerIndex and increases the readerIndex by 1 in this buffer.

public abstract ByteBuf

Returns:

the newly created buffer which contains the transferred bytes
readBytes
(int
the number of bytes to transfer
length
)

Transfers this buffer's data to a newly created buffer starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).

public abstract ByteBuf
readBytes(ByteBuf dst)

Transfers this buffer's data to the specified destination starting at the current readerIndex until the destination becomes non-writable, and increases the readerIndex by the number of the transferred bytes.

public abstract ByteBuf
readBytes(ByteBuf dst, int length)

Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).

public abstract ByteBuf
readBytes(ByteBuf dst, int
the first index of the destination
dstIndex
,
int
the number of bytes to transfer
length
)

Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).

public abstract ByteBuf
readBytes(byte[] dst)

Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= dst.length).

public abstract ByteBuf
readBytes(byte[] dst, int
the first index of the destination
dstIndex
,
int
the number of bytes to transfer
length
)

Transfers this buffer's data to the specified destination starting at the current readerIndex and increases the readerIndex by the number of the transferred bytes (= length).

public abstract ByteBuf
readBytes(ByteBuffer dst)

Transfers this buffer's data to the specified destination starting at the current readerIndex until the destination's position reaches its limit, and increases the readerIndex by the number of the transferred bytes.

public abstract ByteBuf
readBytes(OutputStream out, int
the number of bytes to transfer
length
)

Transfers this buffer's data to the specified stream starting at the current readerIndex.

public abstract int

Returns:

the actual number of bytes written out to the specified channel
readBytes
(GatheringByteChannel out, int
the maximum number of bytes to transfer
length
)

Transfers this buffer's data to the specified stream starting at the current readerIndex.

public abstract int

Returns:

the actual number of bytes written out to the specified channel
readBytes
(FileChannel out, long
the file position at which the transfer is to begin
position
,
int
the maximum number of bytes to transfer
length
)

Transfers this buffer's data starting at the current readerIndex to the specified channel starting at the given file position.

public abstract char
readChar()

Gets a 2-byte UTF-16 character at the current readerIndex and increases the readerIndex by 2 in this buffer.

public abstract CharSequence

Returns:

the sequence
readCharSequence
(int
the length to read
length
,
Charset
that should be used
charset
)

Gets a CharSequence with the given length at the current readerIndex and increases the readerIndex by the given length.

public abstract double
readDouble()

Gets a 64-bit floating point number at the current readerIndex and increases the readerIndex by 8 in this buffer.

public double
readDoubleLE()

Gets a 64-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 8 in this buffer.

public abstract int
readerIndex()

Returns the readerIndex of this buffer.

public abstract ByteBuf
readerIndex(int readerIndex)

Sets the readerIndex of this buffer.

public abstract float
readFloat()

Gets a 32-bit floating point number at the current readerIndex and increases the readerIndex by 4 in this buffer.

public float
readFloatLE()

Gets a 32-bit floating point number at the current readerIndex in Little Endian Byte Order and increases the readerIndex by 4 in this buffer.

public abstract int
readInt()

Gets a 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.

public abstract int
readIntLE()

Gets a 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.

public abstract long
readLong()

Gets a 64-bit integer at the current readerIndex and increases the readerIndex by 8 in this buffer.

public abstract long
readLongLE()

Gets a 64-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 8 in this buffer.

public abstract int
readMedium()

Gets a 24-bit medium integer at the current readerIndex and increases the readerIndex by 3 in this buffer.

public abstract int
readMediumLE()

Gets a 24-bit medium integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 3 in this buffer.

public abstract ByteBuf

Returns:

the newly created slice
readRetainedSlice
(int
the size of the new slice
length
)

Returns a new retained slice of this buffer's sub-region starting at the current readerIndex and increases the readerIndex by the size of the new slice (= length).

public abstract short
readShort()

Gets a 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.

public abstract short
readShortLE()

Gets a 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.

public abstract ByteBuf

Returns:

the newly created slice
readSlice
(int
the size of the new slice
length
)

Returns a new slice of this buffer's sub-region starting at the current readerIndex and increases the readerIndex by the size of the new slice (= length).

public abstract short
readUnsignedByte()

Gets an unsigned byte at the current readerIndex and increases the readerIndex by 1 in this buffer.

public abstract long
readUnsignedInt()

Gets an unsigned 32-bit integer at the current readerIndex and increases the readerIndex by 4 in this buffer.

public abstract long
readUnsignedIntLE()

Gets an unsigned 32-bit integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 4 in this buffer.

public abstract int
readUnsignedMedium()

Gets an unsigned 24-bit medium integer at the current readerIndex and increases the readerIndex by 3 in this buffer.

public abstract int
readUnsignedMediumLE()

Gets an unsigned 24-bit medium integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 3 in this buffer.

public abstract int
readUnsignedShort()

Gets an unsigned 16-bit short integer at the current readerIndex and increases the readerIndex by 2 in this buffer.

public abstract int
readUnsignedShortLE()

Gets an unsigned 16-bit short integer at the current readerIndex in the Little Endian Byte Order and increases the readerIndex by 2 in this buffer.

public abstract ByteBuf
resetReaderIndex()

Repositions the current readerIndex to the marked readerIndex in this buffer.

public abstract ByteBuf
resetWriterIndex()

Repositions the current writerIndex to the marked writerIndex in this buffer.

public abstract ByteBuf
retain(int increment)

Redeclares io.netty.util.ReferenceCounted.retain.

Increases the reference count by the specified increment.
public abstract ByteBuf
retain()

Redeclares io.netty.util.ReferenceCounted.retain.

Increases the reference count by 1.
public abstract ByteBuf
retainedDuplicate()

Returns a retained buffer which shares the whole region of this buffer.

public abstract ByteBuf
retainedSlice()

Returns a retained slice of this buffer's readable bytes.

public abstract ByteBuf
retainedSlice(int index, int length)

Returns a retained slice of this buffer's sub-region.

public abstract ByteBuf
setBoolean(int index, boolean value)

Sets the specified boolean at the specified absolute index in this buffer.

public abstract ByteBuf
setByte(int index, int value)

Sets the specified byte at the specified absolute index in this buffer.

public abstract ByteBuf
setBytes(int index, ByteBuf src)

Transfers the specified source buffer's data to this buffer starting at the specified absolute index until the source buffer becomes unreadable.

public abstract ByteBuf
setBytes(int index, ByteBuf src, int
the number of bytes to transfer
length
)

Transfers the specified source buffer's data to this buffer starting at the specified absolute index.

public abstract ByteBuf
setBytes(int index, ByteBuf src, int
the first index of the source
srcIndex
,
int
the number of bytes to transfer
length
)

Transfers the specified source buffer's data to this buffer starting at the specified absolute index.

public abstract ByteBuf
setBytes(int index, byte[] src)

Transfers the specified source array's data to this buffer starting at the specified absolute index.

public abstract ByteBuf
setBytes(int index, byte[] src, int srcIndex, int length)

Transfers the specified source array's data to this buffer starting at the specified absolute index.

public abstract ByteBuf
setBytes(int index, ByteBuffer src)

Transfers the specified source buffer's data to this buffer starting at the specified absolute index until the source buffer's position reaches its limit.

public abstract int

Returns:

the actual number of bytes read in from the specified channel. -1 if the specified InputStream reached EOF.
setBytes
(int index, InputStream in, int
the number of bytes to transfer
length
)

Transfers the content of the specified source stream to this buffer starting at the specified absolute index.

public abstract int

Returns:

the actual number of bytes read in from the specified channel. -1 if the specified channel is closed or it reached EOF.
setBytes
(int index, ScatteringByteChannel in, int
the maximum number of bytes to transfer
length
)

Transfers the content of the specified source channel to this buffer starting at the specified absolute index.

public abstract int

Returns:

the actual number of bytes read in from the specified channel. -1 if the specified channel is closed or it reached EOF.
setBytes
(int index, FileChannel in, long
the file position at which the transfer is to begin
position
,
int
the maximum number of bytes to transfer
length
)

Transfers the content of the specified source channel starting at the given file position to this buffer starting at the specified absolute index.

public abstract ByteBuf
setChar(int index, int value)

Sets the specified 2-byte UTF-16 character at the specified absolute index in this buffer.

public abstract int

Returns:

the written number of bytes.
setCharSequence
(int
on which the sequence should be written
index
,
CharSequence
to write
sequence
,
Charset
that should be used.
charset
)

Writes the specified CharSequence at the given index.

public abstract ByteBuf
setDouble(int index, double value)

Sets the specified 64-bit floating-point number at the specified absolute index in this buffer.

public ByteBuf
setDoubleLE(int index, double value)

Sets the specified 64-bit floating-point number at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract ByteBuf
setFloat(int index, float value)

Sets the specified 32-bit floating-point number at the specified absolute index in this buffer.

public ByteBuf
setFloatLE(int index, float value)

Sets the specified 32-bit floating-point number at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract ByteBuf
setIndex(int readerIndex, int writerIndex)

Sets the readerIndex and writerIndex of this buffer in one shot.

public abstract ByteBuf
setInt(int index, int value)

Sets the specified 32-bit integer at the specified absolute index in this buffer.

public abstract ByteBuf
setIntLE(int index, int value)

Sets the specified 32-bit integer at the specified absolute index in this buffer with Little Endian byte order .

public abstract ByteBuf
setLong(int index, long value)

Sets the specified 64-bit long integer at the specified absolute index in this buffer.

public abstract ByteBuf
setLongLE(int index, long value)

Sets the specified 64-bit long integer at the specified absolute index in this buffer in Little Endian Byte Order.

public abstract ByteBuf
setMedium(int index, int value)

Sets the specified 24-bit medium integer at the specified absolute index in this buffer.

public abstract ByteBuf
setMediumLE(int index, int value)

Sets the specified 24-bit medium integer at the specified absolute index in this buffer in the Little Endian Byte Order.

public abstract ByteBuf
setShort(int index, int value)

Sets the specified 16-bit short integer at the specified absolute index in this buffer.

public abstract ByteBuf
setShortLE(int index, int value)

Sets the specified 16-bit short integer at the specified absolute index in this buffer with the Little Endian Byte Order.

public abstract ByteBuf
setZero(int index, int
the number of NULs to write to the buffer
length
)

Fills this buffer with NUL (0x00) starting at the specified absolute index.

public abstract ByteBuf
skipBytes(int length)

Increases the current readerIndex by the specified length in this buffer.

public abstract ByteBuf
slice()

Returns a slice of this buffer's readable bytes.

public abstract ByteBuf
slice(int index, int length)

Returns a slice of this buffer's sub-region.

public abstract String
toString(Charset charset)

Decodes this buffer's readable bytes into a string with the specified character set name.

public abstract String
toString(int index, int length, Charset charset)

Decodes this buffer's sub-region into a string with the specified character set.

public abstract String
toString()

Overrides java.lang.Object.toString.

Returns the string representation of this buffer.
public abstract ByteBuf
touch()

Redeclares io.netty.util.ReferenceCounted.touch.

Records the current access location of this object for debugging purposes.
public abstract ByteBuf
touch(Object hint)

Redeclares io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
public abstract ByteBuf

Returns:

null if this buffer is not a wrapper
unwrap
()

Return the underlying buffer instance if this buffer is a wrapper of another buffer.

public abstract int
writableBytes()

Returns the number of writable bytes which is equal to (this.capacity - this.writerIndex).

public abstract ByteBuf
writeBoolean(boolean value)

Sets the specified boolean at the current writerIndex and increases the writerIndex by 1 in this buffer.

public abstract ByteBuf
writeByte(int value)

Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.

public abstract ByteBuf
writeBytes(ByteBuf src)

Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer becomes unreadable, and increases the writerIndex by the number of the transferred bytes.

public abstract ByteBuf
writeBytes(ByteBuf src, int
the number of bytes to transfer
length
)

Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).

public abstract ByteBuf
writeBytes(ByteBuf src, int
the first index of the source
srcIndex
,
int
the number of bytes to transfer
length
)

Transfers the specified source buffer's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).

public abstract ByteBuf
writeBytes(byte[] src)

Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= src.length).

public abstract ByteBuf
writeBytes(byte[] src, int
the first index of the source
srcIndex
,
int
the number of bytes to transfer
length
)

Transfers the specified source array's data to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes (= length).

public abstract ByteBuf
writeBytes(ByteBuffer src)

Transfers the specified source buffer's data to this buffer starting at the current writerIndex until the source buffer's position reaches its limit, and increases the writerIndex by the number of the transferred bytes.

public abstract int

Returns:

the actual number of bytes read in from the specified channel. -1 if the specified InputStream reached EOF.
writeBytes
(InputStream in, int
the number of bytes to transfer
length
)

Transfers the content of the specified stream to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.

public abstract int

Returns:

the actual number of bytes read in from the specified channel. -1 if the specified channel is closed or it reached EOF.
writeBytes
(ScatteringByteChannel in, int
the maximum number of bytes to transfer
length
)

Transfers the content of the specified channel to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.

public abstract int

Returns:

the actual number of bytes read in from the specified channel. -1 if the specified channel is closed or it reached EOF.
writeBytes
(FileChannel in, long
the file position at which the transfer is to begin
position
,
int
the maximum number of bytes to transfer
length
)

Transfers the content of the specified channel starting at the given file position to this buffer starting at the current writerIndex and increases the writerIndex by the number of the transferred bytes.

public abstract ByteBuf
writeChar(int value)

Sets the specified 2-byte UTF-16 character at the current writerIndex and increases the writerIndex by 2 in this buffer.

public abstract int

Returns:

the written number of bytes
writeCharSequence
(CharSequence
to write
sequence
,
Charset
that should be used
charset
)

Writes the specified CharSequence at the current writerIndex and increases the writerIndex by the written bytes.

public abstract ByteBuf
writeDouble(double value)

Sets the specified 64-bit floating point number at the current writerIndex and increases the writerIndex by 8 in this buffer.

public ByteBuf
writeDoubleLE(double value)

Sets the specified 64-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 8 in this buffer.

public abstract ByteBuf
writeFloat(float value)

Sets the specified 32-bit floating point number at the current writerIndex and increases the writerIndex by 4 in this buffer.

public ByteBuf
writeFloatLE(float value)

Sets the specified 32-bit floating point number at the current writerIndex in Little Endian Byte Order and increases the writerIndex by 4 in this buffer.

public abstract ByteBuf
writeInt(int value)

Sets the specified 32-bit integer at the current writerIndex and increases the writerIndex by 4 in this buffer.

public abstract ByteBuf
writeIntLE(int value)

Sets the specified 32-bit integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 4 in this buffer.

public abstract ByteBuf
writeLong(long value)

Sets the specified 64-bit long integer at the current writerIndex and increases the writerIndex by 8 in this buffer.

public abstract ByteBuf
writeLongLE(long value)

Sets the specified 64-bit long integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 8 in this buffer.

public abstract ByteBuf
writeMedium(int value)

Sets the specified 24-bit medium integer at the current writerIndex and increases the writerIndex by 3 in this buffer.

public abstract ByteBuf
writeMediumLE(int value)

Sets the specified 24-bit medium integer at the current writerIndex in the Little Endian Byte Order and increases the writerIndex by 3 in this buffer.

public abstract int
writerIndex()

Returns the writerIndex of this buffer.

public abstract ByteBuf
writerIndex(int writerIndex)

Sets the writerIndex of this buffer.

public abstract ByteBuf
writeShort(int value)

Sets the specified 16-bit short integer at the current writerIndex and increases the writerIndex by 2 in this buffer.

public abstract ByteBuf
writeShortLE(int value)

Sets the specified 16-bit short integer in the Little Endian Byte Order at the current writerIndex and increases the writerIndex by 2 in this buffer.

public abstract ByteBuf
writeZero(int
the number of NULs to write to the buffer
length
)

Fills this buffer with NUL (0x00) starting at the current writerIndex and increases the writerIndex by the specified length.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait