public class ByteBufferUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static byte[] |
EMPTY_BYTES
空 byte 数组
|
| Modifier and Type | Method and Description |
|---|---|
static ByteBuffer |
clone(ByteBuffer original)
ByteBuffer clone
|
static ByteBuffer |
composite(ByteBuffer byteBuffer1,
ByteBuffer byteBuffer2)
组合两个 bytebuffer,把可读部分的组合成一个新的 bytebuffer
|
static ByteBuffer |
copy(ByteBuffer src) |
static void |
copy(ByteBuffer src,
int srcStartIndex,
ByteBuffer dest,
int destStartIndex,
int length) |
static ByteBuffer |
copy(ByteBuffer src,
int startIndex,
int endIndex) |
static String |
hexDump(ByteBuffer byteBuffer)
以16进制 打印 ByteBuffer
|
static int |
indexOf(ByteBuffer buffer,
char theChar,
int maxLength) |
static int |
lineEnd(ByteBuffer buffer) |
static int |
lineEnd(ByteBuffer buffer,
int maxLength) |
static byte |
readByte(ByteBuffer buffer)
read byte
|
static byte[] |
readBytes(ByteBuffer buffer,
int length)
读取 byte 数组
|
static double |
readDouble(ByteBuffer buffer)
read double, 8个字节
|
static double |
readDoubleBE(ByteBuffer buffer)
read double, 8个字节,大端在前
|
static double |
readDoubleLE(ByteBuffer buffer)
read double, 8个字节,小端在前
|
static float |
readFloat(ByteBuffer buffer)
read float, 4个字节,小端
|
static float |
readFloatBE(ByteBuffer buffer)
read float, 4个字节,大端
|
static float |
readFloatLE(ByteBuffer buffer)
read float, 4个字节,小端
|
static int |
readInt(ByteBuffer buffer)
read int, 4个字节
|
static int |
readIntBE(ByteBuffer buffer)
read int, 4个字节,大端在前
|
static int |
readIntLE(ByteBuffer buffer)
read int, 4个字节,小端
|
static String |
readLine(ByteBuffer buffer,
Charset charset)
读取一行
|
static String |
readLine(ByteBuffer buffer,
Charset charset,
int maxLength) |
static long |
readLong(ByteBuffer buffer)
read long, 8个字节
|
static long |
readLongBE(ByteBuffer buffer)
read long, 8个字节,无符号,大端在前
|
static long |
readLongLE(ByteBuffer buffer)
read long, 8个字节,无符号
|
static int |
readMedium(ByteBuffer buffer)
读取3个字节有符号
|
static int |
readMediumBE(ByteBuffer buffer)
读取3个字节有符号,大端在前
|
static int |
readMediumLE(ByteBuffer buffer)
读取3个字节有符号,小端在前
|
static short |
readShort(ByteBuffer buffer)
读取 short
|
static short |
readShortBE(ByteBuffer buffer)
读取 short,大端
|
static short |
readShortLE(ByteBuffer buffer)
读取 short,小端
|
static String |
readString(ByteBuffer buffer,
Charset charset,
char endChar,
int maxLength) |
static String |
readString(ByteBuffer buffer,
int count)
读取字符串
|
static String |
readString(ByteBuffer buffer,
int count,
Charset charset)
读取字符串
|
static short |
readUnsignedByte(ByteBuffer buffer)
read unsigned byte,1个字节无符号
|
static long |
readUnsignedInt(ByteBuffer buffer)
read unsigned int, 4个字节无符号
|
static long |
readUnsignedIntBE(ByteBuffer buffer)
read unsigned int, 4个字节无符号,大端在前
|
static long |
readUnsignedIntLE(ByteBuffer buffer)
read unsigned int, 4个字节无符号
|
static long |
readUnsignedLong(ByteBuffer buffer)
read long, 8个字节,无符号
|
static long |
readUnsignedLongBE(ByteBuffer buffer)
read long, 8个字节,无符号,大端在前
|
static long |
readUnsignedLongLE(ByteBuffer buffer)
read long, 8个字节,无符号
|
static int |
readUnsignedMedium(ByteBuffer buffer)
read unsigned 3个字节无符号
|
static int |
readUnsignedMediumBE(ByteBuffer buffer)
read unsigned 3个字节无符号,大端在前
|
static int |
readUnsignedMediumLE(ByteBuffer buffer)
read unsigned 3个字节无符号,小端在前
|
static long |
readUnsignedNByteBE(ByteBuffer buffer,
int n)
read n 个字节无符号,大端在前
|
static long |
readUnsignedNByteLE(ByteBuffer buffer,
int n)
read n 个字节无符号,小端在前
|
static int |
readUnsignedShort(ByteBuffer buffer)
read unsigned short,2个字节无符号
|
static int |
readUnsignedShortBE(ByteBuffer buffer)
read unsigned short,2个字节无符号,大端在前
|
static int |
readUnsignedShortLE(ByteBuffer buffer)
read unsigned short,2个字节无符号
|
static ByteBuffer |
skipBytes(ByteBuffer buffer,
int skip)
skip bytes
|
static ByteBuffer[] |
split(ByteBuffer src,
int unitSize) |
static String |
toHexString(byte[] bytes)
以16进制 打印字节数组
|
static String |
toString(byte[] buffer)
转成 string
|
static String |
toString(byte[] buffer,
Charset charset)
转成 string
|
static String |
toString(ByteBuffer buffer)
转成 string,读取 ByteBuffer 所有数据
|
static String |
toString(ByteBuffer buffer,
Charset charset)
转成 string,读取 ByteBuffer 所有数据
|
static void |
writeByte(ByteBuffer buffer,
short s)
写出 1 个字节的无符号 byte
|
static void |
writeDouble(ByteBuffer buffer,
double value)
写出 8 个字节的 value
|
static void |
writeDoubleBE(ByteBuffer buffer,
double value)
写出 8 个字节的 value,大端模式
|
static void |
writeDoubleLE(ByteBuffer buffer,
double value)
写出 8 个字节的 value,小端模式
|
static void |
writeFloat(ByteBuffer buffer,
float value)
写出 4 个字节的 float
|
static void |
writeFloatBE(ByteBuffer buffer,
float value)
写出 4 个字节的 float,大端模式
|
static void |
writeFloatLE(ByteBuffer buffer,
float value)
写出 4 个字节的 float,小端模式
|
static void |
writeIntBE(ByteBuffer buffer,
long i)
写出 4 个字节的 int,大端模式
|
static void |
writeIntLE(ByteBuffer buffer,
long i)
写出 4 个字节的 int,小端模式
|
static void |
writeLongBE(ByteBuffer buffer,
long l)
写出 8 个字节的 long,大端模式
|
static void |
writeLongLE(ByteBuffer buffer,
long l)
写出 8 个字节的 long,小端模式
|
static void |
writeMediumBE(ByteBuffer buffer,
int i)
写出 3 个字节的无符号,大端模式
|
static void |
writeMediumLE(ByteBuffer buffer,
int i)
写出 3 个字节的无符号
|
static void |
writeShortBE(ByteBuffer buffer,
int s)
写出 2 个字节的 short,大端模式
|
static void |
writeShortLE(ByteBuffer buffer,
int s)
写出 2 个字节的 short,小端模式
|
public static byte readByte(ByteBuffer buffer)
buffer - ByteBufferpublic static short readUnsignedByte(ByteBuffer buffer)
buffer - ByteBufferpublic static byte[] readBytes(ByteBuffer buffer, int length)
buffer - ByteBufferlength - 长度public static short readShort(ByteBuffer buffer)
buffer - ByteBufferpublic static short readShortLE(ByteBuffer buffer)
buffer - ByteBufferpublic static short readShortBE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readUnsignedShort(ByteBuffer buffer)
buffer - ByteBufferpublic static int readUnsignedShortLE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readUnsignedShortBE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readMedium(ByteBuffer buffer)
buffer - ByteBufferpublic static int readMediumLE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readMediumBE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readUnsignedMedium(ByteBuffer buffer)
buffer - ByteBufferpublic static int readUnsignedMediumLE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readUnsignedMediumBE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readInt(ByteBuffer buffer)
buffer - ByteBufferpublic static int readIntLE(ByteBuffer buffer)
buffer - ByteBufferpublic static int readIntBE(ByteBuffer buffer)
buffer - ByteBufferpublic static long readUnsignedInt(ByteBuffer buffer)
buffer - ByteBufferpublic static long readUnsignedIntLE(ByteBuffer buffer)
buffer - ByteBufferpublic static long readUnsignedIntBE(ByteBuffer buffer)
buffer - ByteBufferpublic static long readUnsignedNByteBE(ByteBuffer buffer, int n)
buffer - ByteBuffern - n 个字符public static long readUnsignedNByteLE(ByteBuffer buffer, int n)
buffer - ByteBuffern - n 个字符public static float readFloat(ByteBuffer buffer)
buffer - ByteBufferpublic static float readFloatLE(ByteBuffer buffer)
buffer - ByteBufferpublic static float readFloatBE(ByteBuffer buffer)
buffer - ByteBufferpublic static long readLong(ByteBuffer buffer)
buffer - ByteBufferpublic static long readLongLE(ByteBuffer buffer)
buffer - ByteBufferpublic static long readLongBE(ByteBuffer buffer)
buffer - ByteBufferpublic static long readUnsignedLong(ByteBuffer buffer)
buffer - ByteBufferpublic static long readUnsignedLongLE(ByteBuffer buffer)
buffer - ByteBufferpublic static long readUnsignedLongBE(ByteBuffer buffer)
buffer - ByteBufferpublic static double readDouble(ByteBuffer buffer)
buffer - ByteBufferpublic static double readDoubleLE(ByteBuffer buffer)
buffer - ByteBufferpublic static double readDoubleBE(ByteBuffer buffer)
buffer - ByteBufferpublic static void writeByte(ByteBuffer buffer, short s)
buffer - ByteBuffers - 数据public static void writeShortLE(ByteBuffer buffer, int s)
buffer - ByteBuffers - 数据public static void writeShortBE(ByteBuffer buffer, int s)
buffer - ByteBuffers - 数据public static void writeMediumLE(ByteBuffer buffer, int i)
buffer - ByteBufferi - 数据public static void writeMediumBE(ByteBuffer buffer, int i)
buffer - ByteBufferi - 数据public static void writeIntLE(ByteBuffer buffer, long i)
buffer - ByteBufferi - 数据public static void writeIntBE(ByteBuffer buffer, long i)
buffer - ByteBufferi - 数据public static void writeFloat(ByteBuffer buffer, float value)
buffer - ByteBuffervalue - 数据public static void writeFloatLE(ByteBuffer buffer, float value)
buffer - ByteBuffervalue - 数据public static void writeFloatBE(ByteBuffer buffer, float value)
buffer - ByteBuffervalue - 数据public static void writeLongLE(ByteBuffer buffer, long l)
buffer - ByteBufferl - 数据public static void writeLongBE(ByteBuffer buffer, long l)
buffer - ByteBufferl - 数据public static void writeDouble(ByteBuffer buffer, double value)
buffer - ByteBuffervalue - 数据public static void writeDoubleLE(ByteBuffer buffer, double value)
buffer - ByteBuffervalue - 数据public static void writeDoubleBE(ByteBuffer buffer, double value)
buffer - ByteBuffervalue - 数据public static ByteBuffer skipBytes(ByteBuffer buffer, int skip)
buffer - ByteBufferskip - skip bytespublic static ByteBuffer composite(ByteBuffer byteBuffer1, ByteBuffer byteBuffer2)
byteBuffer1 - ByteBufferbyteBuffer2 - ByteBufferpublic static ByteBuffer clone(ByteBuffer original)
original - ByteBufferpublic static void copy(ByteBuffer src, int srcStartIndex, ByteBuffer dest, int destStartIndex, int length)
src - ByteBuffersrcStartIndex - srcStartIndexdest - ByteBufferdestStartIndex - destStartIndexlength - lengthpublic static ByteBuffer copy(ByteBuffer src, int startIndex, int endIndex)
src - 本方法不会改变position等指针变量startIndex - 从0开始endIndex - endIndexpublic static ByteBuffer copy(ByteBuffer src)
src - 本方法不会改变position等指针变量public static ByteBuffer[] split(ByteBuffer src, int unitSize)
src - ByteBufferunitSize - 每个单元的大小public static int lineEnd(ByteBuffer buffer)
buffer - ByteBufferpublic static int lineEnd(ByteBuffer buffer, int maxLength)
buffer - ByteBuffermaxLength - maxLengthpublic static int indexOf(ByteBuffer buffer, char theChar, int maxLength)
buffer - position会被移动theChar - 结束maxLength - maxLengthpublic static String readLine(ByteBuffer buffer, Charset charset)
buffer - ByteBuffercharset - Charsetpublic static String readLine(ByteBuffer buffer, Charset charset, int maxLength)
buffer - ByteBuffercharset - CharsetmaxLength - maxLengthpublic static String readString(ByteBuffer buffer, int count)
buffer - ByteBuffercount - countpublic static String readString(ByteBuffer buffer, int count, Charset charset)
buffer - ByteBuffercount - countcharset - Charsetpublic static String readString(ByteBuffer buffer, Charset charset, char endChar, int maxLength)
buffer - ByteBuffercharset - CharsetendChar - endCharmaxLength - maxLengthpublic static String toString(ByteBuffer buffer)
buffer - ByteBufferpublic static String toString(ByteBuffer buffer, Charset charset)
buffer - ByteBuffercharset - Charsetpublic static String toString(byte[] buffer)
buffer - ByteBufferpublic static String toString(byte[] buffer, Charset charset)
buffer - ByteBuffercharset - Charsetpublic static String hexDump(ByteBuffer byteBuffer)
byteBuffer - ByteBufferpublic static String toHexString(byte[] bytes)
bytes - byte[]Copyright © 2025. All rights reserved.