public interface ByteBuf extends ByteChannel
| 限定符和类型 | 方法和说明 |
|---|---|
ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator which created this buffer. |
byte[] |
array()
ByteBuf 的字节数组形态
|
ByteBuffer |
asByteBuffer()
返回 ByteBuffer 形态,PooledNioByteBuf 不支持该方法
|
int |
capacity()
最大限制
|
default void |
clear()
reset the markWriter, and skip all readable data
|
default void |
close() |
ByteBuf |
copy()
复制个 ByteBuf , 连同 buffer 的数据一起复制
|
default int |
expect(char expect,
Charset charset)
查找下一个 expect 字符的出现的位置(使用指定的编码),该方法不会更新 readerIndex 值。
|
default int |
expect(String expect,
Charset charset)
查找下一个 expect 字符串的出现的位置(使用指定的编码),该方法不会更新 readerIndex 值。
|
default int |
expectLast(char expect,
Charset charset)
查找最后一个 expect 字符的出现的位置(使用指定的编码),该方法不会更新 readerIndex 值。
|
default int |
expectLast(String expect,
Charset charset)
查找最后一个 expect 字符串的出现的位置(使用指定的编码),该方法不会更新 readerIndex 值。
|
default int |
expectLine()
查找最近的一个 '\n',该方法不会更新 readerIndex 值。
|
default ByteBuf |
flush()
same as markWriter()
|
void |
free()
释放 Buffer 占用的内存
|
byte |
getByte(int offset)
从 offset 偏移量的位置上开始读取 1 字节。
|
default int |
getBytes(int offset,
byte[] b)
从 offset 偏移量的位置上开始读取一定数量的字节,并将它们存储到缓冲区数组 b 中。
|
int |
getBytes(int offset,
byte[] b,
int off,
int len)
从 offset 偏移量的位置上开始读取 len 数量的字节,并将它们存储到 off 位置开始的缓冲区数组 b 中。
|
default float |
getFloat32(int offset)
读取 4 字节的 float(大端字节序),该方法不会更新 readerIndex 值。
|
default float |
getFloat32LE(int offset)
读取 4 字节的 float(小端字节序),该方法不会更新 readerIndex 值。
|
default double |
getFloat64(int offset)
读取 8 字节的 double(大端字节序),该方法不会更新 readerIndex 值。
|
default double |
getFloat64LE(int offset)
读取 8 字节的 double(小端字节序),该方法不会更新 readerIndex 值。
|
short |
getInt16(int offset)
读取 2 字节的 short(大端字节序),该方法不会更新 readerIndex 值。
|
short |
getInt16LE(int offset)
读取 2 字节的 short(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt24(int offset)
读取 3 字节的 int(大端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt24LE(int offset)
读取 3 字节的 int(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt32(int offset)
读取 4 字节的 int(大端字节序),该方法不会更新 readerIndex 值。
|
int |
getInt32LE(int offset)
读取 4 字节的 int(小端字节序),该方法不会更新 readerIndex 值。
|
long |
getInt64(int offset)
读取 8 字节的 long(大端字节序),该方法不会更新 readerIndex 值。
|
long |
getInt64LE(int offset)
读取 8 字节的 long(小端字节序),该方法不会更新 readerIndex 值。
|
default String |
getString(int offset,
int len,
Charset charset)
从 offset 开始读取 len 个字节,并构造一个 String,该方法不会更新 readerIndex 值。
|
int |
getUInt16(int offset)
读取 2 字节的 无符号 sort(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getUInt16LE(int offset)
读取 2 字节的 无符号 sort(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getUInt24(int offset)
读取 3 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
int |
getUInt24LE(int offset)
读取 3 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
long |
getUInt32(int offset)
读取 4 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
long |
getUInt32LE(int offset)
读取 4 字节的 无符号 int(小端字节序),该方法不会更新 readerIndex 值。
|
short |
getUInt8(int offset)
读取 1 字节的 byte 返回 0~255 之间的一个数(小端字节序),该方法不会更新 readerIndex 值。
|
default boolean |
hasLine()
具有行结尾
|
default boolean |
hasReadable()
可以进行读
|
default boolean |
hasWritable()
可以进行写入
|
boolean |
isDirect()
ByteBuf 是否为堆外方式
|
boolean |
isFree()
是否已经释放
|
ByteBuf |
markReader()
Marks the current
readerIndex in this buffer. |
ByteBuf |
markWriter()
Marks the current
writerIndex in this buffer. |
ByteOrder |
order()
字节序
|
ByteBuf |
order(ByteOrder newOrder)
设置字节序
|
default int |
read(ByteBuf dst)
use copy to dst
|
int |
read(ByteBuffer dst)
use copy to dst
|
int |
read(ByteBuf dst,
int len)
use copy to dst
|
int |
readableBytes()
Returns the number of readable bytes which is equal to
(this.markedWriterIndex - this.readerIndex). |
byte |
readByte()
读取 1 字节。
|
int |
readBytes()
Returns the number of read bytes which is equal to
(readIndex - readMark). |
default int |
readBytes(byte[] b)
读取一定数量的字节,并将它们存储到缓冲区数组 b 中。
|
int |
readBytes(byte[] b,
int off,
int len)
读取 len 数量的字节,并将它们存储到 off 位置开始的缓冲区数组 b 中。
|
int |
readerIndex()
Returns the
readerIndex of this buffer. |
default String |
readExpect(char expect,
Charset charset)
从当前位置开始读取,直到遇到第一个 expect 字符串读完。
|
default String |
readExpect(String expect,
Charset charset)
从当前位置开始读取,直到遇到第一个 expect 字符串读完。
|
default String |
readExpectLast(char expect,
Charset charset)
从当前位置开始读取,直到遇到最后一个 expect 字符串读完。
|
default String |
readExpectLast(String expect,
Charset charset)
从当前位置开始读取,直到遇到最后一个 expect 字符串读完。
|
default float |
readFloat32()
读取 4 字节的 float(大端字节序),读取后 readerIndex 会增加 4。
|
default float |
readFloat32LE()
读取 4 字节的 float(小端字节序),读取后 readerIndex 会增加 4。
|
default double |
readFloat64()
读取 8 字节的 double(大端字节序),读取后 readerIndex 会增加 8。
|
default double |
readFloat64LE()
读取 8 字节的 double(小端字节序),读取后 readerIndex 会增加 8。
|
short |
readInt16()
读取 2 字节的 short(大端字节序),读取后 readerIndex 会增加 2。
|
short |
readInt16LE()
读取 2 字节的 short(小端字节序),读取后 readerIndex 会增加 2。
|
int |
readInt24()
读取 3 字节的 int(大端字节序),读取后 readerIndex 会增加 3。
|
int |
readInt24LE()
读取 3 字节的 int(小端字节序),读取后 readerIndex 会增加 3。
|
int |
readInt32()
读取 4 字节的 int(大端字节序),读取后 readerIndex 会增加 4。
|
int |
readInt32LE()
读取 4 字节的 int(小端字节序),读取后 readerIndex 会增加 4。
|
long |
readInt64()
读取 8 字节的 long(大端字节序),读取后 readerIndex 会增加 8。
|
long |
readInt64LE()
读取 8 字节的 long(小端字节序),读取后 readerIndex 会增加 8。
|
default String |
readLine()
读一整行
|
default String |
readLine(Charset charset)
读一整行
|
default String |
readString(int len,
Charset charset)
读取 len 字节并将其构造成 String,读取后 readerIndex 会增加 len。
|
int |
readUInt16()
读取 2 字节的 无符号 sort(大端字节序),读取后 readerIndex 会增加 2。
|
int |
readUInt16LE()
读取 2 字节的 无符号 sort(小端字节序),读取后 readerIndex 会增加 2。
|
int |
readUInt24()
读取 3 字节的 无符号 int(大端字节序),读取后 readerIndex 会增加 3。
|
int |
readUInt24LE()
读取 3 字节的 无符号 int(小端字节序),读取后 readerIndex 会增加 3。
|
long |
readUInt32()
读取 4 字节的 无符号 int(大端字节序),读取后 readerIndex 会增加 4。
|
long |
readUInt32LE()
读取 4 字节的 无符号 int(小端字节序),读取后 readerIndex 会增加 4。
|
short |
readUInt8()
读取 1 字节的 byte 返回 0~255 之间的一个数(大端字节序),读取后 readerIndex 会增加 1。
|
ByteBuf |
resetReader()
Repositions the current
readerIndex to the marked
readerIndex in this buffer. |
ByteBuf |
resetWriter()
Repositions the current
writerIndex to the marked
writerIndex in this buffer. |
void |
setByte(int offset,
byte n)
在 offset 偏移量的位置上向后覆盖方式写入 1 字节的 byte,该方法不会更新 writerIndex 值。
|
void |
setBytes(int offset,
byte[] b)
在 offset 偏移量的位置上向后覆盖方式写入 b 数组的数据,该方法不会更新 writerIndex 值。
|
void |
setBytes(int offset,
byte[] b,
int off,
int len)
在 offset 偏移量的位置上向后覆盖方式写入 b 数组的数据,该方法不会更新 writerIndex 值。
|
default void |
setFloat32(int offset,
float n)
在 offset 偏移量的位置上向后覆盖方式写入 4 字节长度的 float(大端字节序),该方法不会更新 writerIndex 值。
|
default void |
setFloat32LE(int offset,
float n)
在 offset 偏移量的位置上向后覆盖方式写入 4 字节长度的 float(小端字节序),该方法不会更新 writerIndex 值。
|
default void |
setFloat64(int offset,
double n)
在 offset 偏移量的位置上向后覆盖方式写入 8 字节长度的 float(大端字节序),该方法不会更新 writerIndex 值。
|
default void |
setFloat64LE(int offset,
double n)
在 offset 偏移量的位置上向后覆盖方式写入 8 字节长度的 float(小端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt16(int offset,
short n)
在 offset 偏移量的位置上向后覆盖方式写入 2 字节长度的 sort(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt16LE(int offset,
short n)
在 offset 偏移量的位置上向后覆盖方式写入 2 字节长度的 sort(小端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt24(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 3 字节长度的 int(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt24LE(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 3 字节长度的 int(小端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt32(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 4 字节长度的 int(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt32LE(int offset,
int n)
在 offset 偏移量的位置上向后覆盖方式写入 4 字节长度的 int(小端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt64(int offset,
long n)
在 offset 偏移量的位置上向后覆盖方式写入 8 字节长度的 long(大端字节序),该方法不会更新 writerIndex 值。
|
void |
setInt64LE(int offset,
long n)
在 offset 偏移量的位置上向后覆盖方式写入 8 字节长度的 long(小端字节序),该方法不会更新 writerIndex 值。
|
default int |
setString(int offset,
String string,
Charset charset)
在 offset 偏移量的位置上向后覆盖方式写入字符串,字符串会通过 str.getBytes(charset) 方式转换为字节数组,该方法不会更新 writerIndex 值。
|
ByteBuf |
skipReadableBytes(int length) |
ByteBuf |
skipWritableBytes(int length) |
int |
writableBytes()
Returns the number of writable bytes which is equal to
(maxCapacity - (writerIndex - readMark)). |
int |
write(ByteBuf src)
use copy form src ByteBuffer
|
int |
write(ByteBuffer src)
use copy form src ByteBuffer
|
void |
writeByte(byte n)
写入 1 字节的 byte,写入后 writerIndex 会 + 1。
|
default void |
writeBytes(byte[] b)
数据写入,写入后 writerIndex 会增加 b.length。
|
void |
writeBytes(byte[] b,
int off,
int len)
数据写入,写入后 writerIndex 会增加 len。
|
int |
writedBytes()
Returns the number of writed bytes which is equal to
(writerIndex - writerMark). |
default void |
writeFloat32(float n)
写入 4 字节的 float(大端字节序),写入后 writerIndex 会 + 4。
|
default void |
writeFloat32LE(float n)
写入 4 字节的 float(小端字节序),写入后 writerIndex 会 + 4。
|
default void |
writeFloat64(double n)
写入 8 字节的 double(大端字节序),写入后 writerIndex 会 + 8。
|
default void |
writeFloat64LE(double n)
写入 8 字节的 double(小端字节序),写入后 writerIndex 会 + 8。
|
void |
writeInt16(short n)
写入 2 字节的 sort(大端字节序),写入后 writerIndex 会 + 2。
|
void |
writeInt16LE(short n)
写入 2 字节的 sort(小端字节序),写入后 writerIndex 会 + 2。
|
void |
writeInt24(int n)
写入 3 字节的 int(大端字节序),写入后 writerIndex 会 + 3。
|
void |
writeInt24LE(int n)
写入 3 字节的 int(小端字节序),写入后 writerIndex 会 + 3。
|
void |
writeInt32(int n)
写入 4 字节的 int(大端字节序),写入后 writerIndex 会 + 4。
|
void |
writeInt32LE(int n)
写入 4 字节的 int(小端字节序),写入后 writerIndex 会 + 4。
|
void |
writeInt64(long n)
写入 8 字节的 long(大端字节序),写入后 writerIndex 会 + 8。
|
void |
writeInt64LE(long n)
写入 8 字节的 int(小端字节序),写入后 writerIndex 会 + 8。
|
int |
writerIndex()
Returns the
writerIndex of this buffer. |
default int |
writeString(String string,
Charset charset)
字符串会以 str.getBytes(charset) 方式转换为字节数组并写入缓存。
|
void |
writeUInt32(long n)
写入 4 字节的无符号 int(大端字节序),写入后 writerIndex 会 + 4。
|
void |
writeUInt32LE(long n)
写入 4 字节的无符号 int(小端字节序),写入后 writerIndex 会 + 4。
|
ByteBufAllocator alloc()
ByteBufAllocator which created this buffer.int readerIndex()
readerIndex of this buffer.int writerIndex()
writerIndex of this buffer.int capacity()
byte[] array()
boolean isDirect()
ByteBuf copy()
ByteBuffer asByteBuffer()
ByteOrder order()
void free()
default void close()
throws IOException
close 在接口中 AutoCloseableclose 在接口中 Channelclose 在接口中 CloseableIOExceptionboolean isFree()
int readableBytes()
(this.markedWriterIndex - this.readerIndex).int readBytes()
(readIndex - readMark).default boolean hasReadable()
int writableBytes()
(maxCapacity - (writerIndex - readMark)).int writedBytes()
(writerIndex - writerMark).default boolean hasWritable()
ByteBuf markReader()
readerIndex in this buffer.
You can reposition the current readerIndex to the marked readerIndex by calling resetReader().
The initial value of the marked readerIndex is 0.ByteBuf markWriter()
writerIndex in this buffer.
You can reposition the current writerIndex to the marked writerIndex by calling resetWriter().
The initial value of the marked writerIndex is 0.default ByteBuf flush() throws IOException
IOExceptiondefault void clear()
ByteBuf resetReader()
readerIndex to the marked
readerIndex in this buffer.IndexOutOfBoundsException - if the current writerIndex is less than the marked readerIndexByteBuf resetWriter()
writerIndex to the marked
writerIndex in this buffer.IndexOutOfBoundsException - if the current readerIndex is greater than the marked writerIndexByteBuf skipReadableBytes(int length)
ByteBuf skipWritableBytes(int length)
void writeByte(byte n)
IndexOutOfBoundsException 异常default void writeBytes(byte[] b)
IndexOutOfBoundsException 异常void writeBytes(byte[] b,
int off,
int len)
IndexOutOfBoundsException 异常void writeInt16(short n)
IndexOutOfBoundsException 异常void writeInt24(int n)
IndexOutOfBoundsException 异常void writeInt32(int n)
IndexOutOfBoundsException 异常void writeUInt32(long n)
IndexOutOfBoundsException 异常void writeInt64(long n)
IndexOutOfBoundsException 异常default void writeFloat32(float n)
IndexOutOfBoundsException 异常default void writeFloat64(double n)
IndexOutOfBoundsException 异常void writeInt16LE(short n)
IndexOutOfBoundsException 异常void writeInt24LE(int n)
IndexOutOfBoundsException 异常void writeInt32LE(int n)
IndexOutOfBoundsException 异常void writeUInt32LE(long n)
IndexOutOfBoundsException 异常void writeInt64LE(long n)
IndexOutOfBoundsException 异常default void writeFloat32LE(float n)
IndexOutOfBoundsException 异常default void writeFloat64LE(double n)
IndexOutOfBoundsException 异常int write(ByteBuffer src)
write 在接口中 WritableByteChannelint write(ByteBuf src)
default int writeString(String string, Charset charset)
IndexOutOfBoundsException 异常void setByte(int offset,
byte n)
IndexOutOfBoundsException 异常void setBytes(int offset,
byte[] b)
IndexOutOfBoundsException 异常void setBytes(int offset,
byte[] b,
int off,
int len)
IndexOutOfBoundsException 异常void setInt16(int offset,
short n)
IndexOutOfBoundsException 异常void setInt24(int offset,
int n)
IndexOutOfBoundsException 异常void setInt32(int offset,
int n)
IndexOutOfBoundsException 异常void setInt64(int offset,
long n)
IndexOutOfBoundsException 异常default void setFloat32(int offset,
float n)
IndexOutOfBoundsException 异常default void setFloat64(int offset,
double n)
IndexOutOfBoundsException 异常void setInt16LE(int offset,
short n)
IndexOutOfBoundsException 异常void setInt24LE(int offset,
int n)
IndexOutOfBoundsException 异常void setInt32LE(int offset,
int n)
IndexOutOfBoundsException 异常void setInt64LE(int offset,
long n)
IndexOutOfBoundsException 异常default void setFloat32LE(int offset,
float n)
IndexOutOfBoundsException 异常default void setFloat64LE(int offset,
double n)
IndexOutOfBoundsException 异常default int setString(int offset,
String string,
Charset charset)
IndexOutOfBoundsException 异常byte readByte()
IndexOutOfBoundsException 异常default int readBytes(byte[] b)
int readBytes(byte[] b,
int off,
int len)
short readInt16()
IndexOutOfBoundsException 异常int readInt24()
IndexOutOfBoundsException 异常int readInt32()
IndexOutOfBoundsException 异常long readInt64()
IndexOutOfBoundsException 异常default float readFloat32()
IndexOutOfBoundsException 异常default double readFloat64()
IndexOutOfBoundsException 异常short readInt16LE()
IndexOutOfBoundsException 异常int readInt24LE()
IndexOutOfBoundsException 异常int readInt32LE()
IndexOutOfBoundsException 异常long readInt64LE()
IndexOutOfBoundsException 异常default float readFloat32LE()
IndexOutOfBoundsException 异常default double readFloat64LE()
IndexOutOfBoundsException 异常int read(ByteBuffer dst)
read 在接口中 ReadableByteChanneldefault int read(ByteBuf dst)
int read(ByteBuf dst, int len)
dst - dst ByteBuflen - max copy Sizedefault String readString(int len, Charset charset)
IndexOutOfBoundsException 异常byte getByte(int offset)
IndexOutOfBoundsException 异常default int getBytes(int offset,
byte[] b)
int getBytes(int offset,
byte[] b,
int off,
int len)
short getInt16(int offset)
IndexOutOfBoundsException 异常int getInt24(int offset)
IndexOutOfBoundsException 异常int getInt32(int offset)
IndexOutOfBoundsException 异常long getInt64(int offset)
IndexOutOfBoundsException 异常default float getFloat32(int offset)
IndexOutOfBoundsException 异常default double getFloat64(int offset)
IndexOutOfBoundsException 异常short getInt16LE(int offset)
IndexOutOfBoundsException 异常int getInt24LE(int offset)
IndexOutOfBoundsException 异常int getInt32LE(int offset)
IndexOutOfBoundsException 异常long getInt64LE(int offset)
IndexOutOfBoundsException 异常default float getFloat32LE(int offset)
IndexOutOfBoundsException 异常default double getFloat64LE(int offset)
IndexOutOfBoundsException 异常default String getString(int offset, int len, Charset charset)
IndexOutOfBoundsException 异常short readUInt8()
IndexOutOfBoundsException 异常int readUInt16()
IndexOutOfBoundsException 异常int readUInt24()
IndexOutOfBoundsException 异常long readUInt32()
IndexOutOfBoundsException 异常int readUInt16LE()
IndexOutOfBoundsException 异常int readUInt24LE()
IndexOutOfBoundsException 异常long readUInt32LE()
IndexOutOfBoundsException 异常short getUInt8(int offset)
IndexOutOfBoundsException 异常int getUInt16(int offset)
IndexOutOfBoundsException 异常int getUInt24(int offset)
IndexOutOfBoundsException 异常long getUInt32(int offset)
IndexOutOfBoundsException 异常int getUInt16LE(int offset)
IndexOutOfBoundsException 异常int getUInt24LE(int offset)
IndexOutOfBoundsException 异常long getUInt32LE(int offset)
IndexOutOfBoundsException 异常default int expect(String expect, Charset charset)
default int expectLine()
default boolean hasLine()
default String readLine()
default int expect(char expect,
Charset charset)
default String readExpect(String expect, Charset charset)
default String readExpect(char expect, Charset charset)
default int expectLast(String expect, Charset charset)
default int expectLast(char expect,
Charset charset)
default String readExpectLast(String expect, Charset charset)
Copyright © 2022–2024. All rights reserved.