T - buffer typepublic interface ByteBuffer<T>
| Modifier and Type | Method and Description | 
|---|---|
T | 
asNativeBuffer()  | 
ByteBuffer | 
asNioBuffer()
Exposes this buffer's readable bytes as an NIO  
ByteBuffer. | 
ByteBuffer | 
asNioBuffer(int index,
           int length)
Exposes this buffer's sub-region as an NIO  
ByteBuffer. | 
ByteBuffer | 
capacity(int capacity)
Adjusts the capacity of this buffer. 
 | 
byte | 
getByte(int index)
Get the byte at the specified index. 
 | 
int | 
indexOf(byte b)
Find the index of the first occurrence of the given byte. 
 | 
int | 
maxCapacity()
Returns the maximum allowed capacity of this buffer. 
 | 
byte | 
read()
Gets a byte at the current  
readerIndex and increases
 the readerIndex by 1 in this buffer. | 
ByteBuffer | 
read(byte[] destination)
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). | 
ByteBuffer | 
read(byte[] destination,
    int offset,
    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). | 
int | 
readableBytes()
Returns the number of readable bytes which is equal to
  
(this.writerIndex - this.readerIndex). | 
CharSequence | 
readCharSequence(int length,
                Charset charset)
Gets a  
CharSequence with the given length at the current readerIndex
 and increases the readerIndex by the given length. | 
int | 
readerIndex()
Returns the  
readerIndex of this buffer. | 
ByteBuffer | 
readerIndex(int readPosition)
Sets the  
readerIndex of this buffer. | 
ByteBuffer | 
slice(int index,
     int length)
Create a new  
ByteBuffer whose contents is a shared subsequence of this
 data buffer's content. | 
byte[] | 
toByteArray()
Create a copy of the underlying storage from  
buf into a byte array. | 
InputStream | 
toInputStream()
Convert the  
ByteBuffer into an input stream. | 
OutputStream | 
toOutputStream()
Convert the  
ByteBuffer into an output stream. | 
String | 
toString(Charset charset)
To string. 
 | 
int | 
writableBytes()
Returns the number of writable bytes which is equal to
  
(this.capacity - this.writerIndex). | 
ByteBuffer | 
write(byte b)
Sets the specified byte at the current  
writerIndex
 and increases the writerIndex by 1 in this buffer. | 
ByteBuffer | 
write(byte[] source)
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). | 
ByteBuffer | 
write(byte[] source,
     int offset,
     int 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). | 
ByteBuffer | 
write(ByteBuffer... buffers)
Write the given  
ByteBuffer instances to this buffer. | 
ByteBuffer | 
write(ByteBuffer... buffers)
Write the given  
ByteBuffer instances to this buffer. | 
ByteBuffer | 
write(CharSequence source,
     Charset charset)
Transfers the specified source CharSequence's data to this buffer starting at
 the current  
writerIndex and increases the writerIndex
 by the number of the transferred bytes (= src.length). | 
int | 
writerIndex()
Returns the  
writerIndex of this buffer. | 
ByteBuffer | 
writerIndex(int position)
Sets the  
writerIndex of this buffer. | 
T asNativeBuffer()
int readableBytes()
(this.writerIndex - this.readerIndex).int writableBytes()
(this.capacity - this.writerIndex).int maxCapacity()
capacity(int) or
 IllegalArgumentException.ByteBuffer capacity(int capacity)
newCapacity is less than the current
 capacity, the content of this buffer is truncated.  If the newCapacity is greater
 than the current capacity, the buffer is appended with unspecified data whose length is
 (newCapacity - currentCapacity).capacity - capacityint readerIndex()
readerIndex of this buffer.ByteBuffer readerIndex(int readPosition)
readerIndex of this buffer.readPosition - readPositionIndexOutOfBoundsException - if the specified readerIndex is
                                   less than 0 or
                                   greater than this.writerIndexint writerIndex()
writerIndex of this buffer.ByteBuffer writerIndex(int position)
writerIndex of this buffer.position - The positionIndexOutOfBoundsException - if the specified writerIndex is
                                   less than this.readerIndex or
                                   greater than this.capacitybyte read()
readerIndex and increases
 the readerIndex by 1 in this buffer.IndexOutOfBoundsException - if this.readableBytes is less than 1CharSequence readCharSequence(int length, Charset charset)
CharSequence with the given length at the current readerIndex
 and increases the readerIndex by the given length.length - the length to readcharset - that should be usedIndexOutOfBoundsException - if length is greater than this.readableBytesByteBuffer read(byte[] destination)
readerIndex and increases the readerIndex
 by the number of the transferred bytes (= dst.length).destination - destinationIndexOutOfBoundsException - if dst.length is greater than this.readableBytesByteBuffer read(byte[] destination, int offset, int length)
readerIndex and increases the readerIndex
 by the number of the transferred bytes (= length).destination - The destination byte arrayoffset - the first index of the destinationlength - the number of bytes to transferIndexOutOfBoundsException - if the specified dstIndex is less than 0,
                                   if length is greater than this.readableBytes, or
                                   if dstIndex + length is greater than dst.lengthByteBuffer write(byte b)
writerIndex
 and increases the writerIndex by 1 in this buffer.
 The 24 high-order bits of the specified value are ignored.b - The byte to writeIndexOutOfBoundsException - if this.writableBytes is less than 1ByteBuffer write(byte[] source)
writerIndex and increases the writerIndex
 by the number of the transferred bytes (= src.length).source - The source bytesIndexOutOfBoundsException - if src.length is greater than this.writableBytesByteBuffer write(CharSequence source, Charset charset)
writerIndex and increases the writerIndex
 by the number of the transferred bytes (= src.length).source - The char sequencecharset - The charsetByteBuffer write(byte[] source, int offset, int length)
writerIndex and increases the writerIndex
 by the number of the transferred bytes (= length).source - The source byte arrayoffset - the first index of the sourcelength - the number of bytes to transferIndexOutOfBoundsException - if the specified srcIndex is less than 0,
                                   if srcIndex + length is greater than
                                   src.length, or
                                   if length is greater than this.writableBytesByteBuffer write(ByteBuffer... buffers)
ByteBuffer instances to this buffer.buffers - The buffers to writeByteBuffer write(ByteBuffer... buffers)
ByteBuffer instances to this buffer.buffers - The buffers to writeByteBuffer slice(int index, int length)
ByteBuffer whose contents is a shared subsequence of this
 data buffer's content.  Data between this byte buffer and the returned buffer is
 shared; though changes in the returned buffer's position will not be reflected
 in the reading nor writing position of this data buffer.index - the index at which to start the slicelength - the length of the sliceByteBuffer asNioBuffer()
ByteBuffer.  The returned buffer
 shares the content with this buffer, while changing the position and limit of the returned
 NIO buffer does not affect the indexes and marks of this buffer.  This method is identical
 to buf.nioBuffer(buf.readerIndex(), buf.readableBytes()).  This method does not
 modify readerIndex or writerIndex of this buffer.  Please note that the
 returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic
 buffer and it adjusted its capacity.UnsupportedOperationException - if this buffer cannot create a ByteBuffer
                                       that shares the content with itselfByteBuffer asNioBuffer(int index, int length)
ByteBuffer.  The returned buffer
 shares the content with this buffer, while changing the position and limit of the returned
 NIO buffer does not affect the indexes and marks of this buffer.  This method does not
 modify readerIndex or writerIndex of this buffer.  Please note that the
 returned NIO buffer will not see the changes of this buffer if this buffer is a dynamic
 buffer and it adjusted its capacity.index - The indexlength - The lengthUnsupportedOperationException - if this buffer cannot create a ByteBuffer
                                       that shares the content with itselfInputStream toInputStream()
ByteBuffer into an input stream.OutputStream toOutputStream()
ByteBuffer into an output stream.byte[] toByteArray()
buf into a byte array.
 The copy will start at readerIndex() and copy readableBytes() bytes.String toString(Charset charset)
charset - converted charsetint indexOf(byte b)
b - The byte to findbyte getByte(int index)
index - The index