public class ByteBufferUtils extends Object
Constructor and Description |
---|
ByteBufferUtils() |
Modifier and Type | Method and Description |
---|---|
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 |
getUtf8(byte[] bytes)
获取utf-8字符串
|
static int |
indexOf(ByteBuffer buffer,
char theChar,
int maxlength) |
static int |
lineEnd(ByteBuffer buffer) |
static int |
lineEnd(ByteBuffer buffer,
int maxlength) |
static byte |
read(ByteBuffer buffer)
读取byte
|
static byte[] |
readBytes(ByteBuffer buffer,
int length) |
static String |
readLine(ByteBuffer buffer,
String charset) |
static String |
readLine(ByteBuffer buffer,
String charset,
Integer maxlength) |
static short |
readShort(ByteBuffer buffer)
读取short
|
static String |
readString(ByteBuffer buffer,
int length,
String charset) |
static String |
readString(ByteBuffer buffer,
String charset,
char endChar,
Integer maxlength) |
static int |
readUB1(ByteBuffer buffer) |
static int |
readUB2(ByteBuffer buffer) |
static int |
readUB2WithBigEdian(ByteBuffer buffer) |
static long |
readUB4(ByteBuffer buffer) |
static long |
readUB4WithBigEdian(ByteBuffer buffer) |
static ByteBuffer[] |
split(ByteBuffer src,
int unitSize) |
static void |
writeUB2(ByteBuffer buffer,
int i) |
static void |
writeUB2WithBigEdian(ByteBuffer buffer,
int i) |
static void |
writeUB4(ByteBuffer buffer,
long l) |
static void |
writeUB4WithBigEdian(ByteBuffer buffer,
long l) |
public static ByteBuffer composite(ByteBuffer byteBuffer1, ByteBuffer byteBuffer2)
byteBuffer1
- byteBuffer2
- public static void copy(ByteBuffer src, int srcStartindex, ByteBuffer dest, int destStartIndex, int length)
src
- srcStartindex
- dest
- destStartIndex
- length
- public static ByteBuffer copy(ByteBuffer src, int startindex, int endindex)
src
- 本方法不会改变position等指针变量startindex
- 从0开始endindex
- public static ByteBuffer copy(ByteBuffer src)
src
- 本方法不会改变position等指针变量public static ByteBuffer[] split(ByteBuffer src, int unitSize)
src
- unitSize
- 每个单元的大小public static int lineEnd(ByteBuffer buffer) throws LengthOverflowException
buffer
- LengthOverflowException
public static int lineEnd(ByteBuffer buffer, int maxlength) throws LengthOverflowException
buffer
- maxlength
- LengthOverflowException
public static int indexOf(ByteBuffer buffer, char theChar, int maxlength) throws LengthOverflowException
buffer
- position会被移动theChar
- 结束maxlength
- LengthOverflowException
public static byte[] readBytes(ByteBuffer buffer, int length)
public static String readString(ByteBuffer buffer, int length, String charset) throws UnsupportedEncodingException
buffer
- length
- charset
- UnsupportedEncodingException
public static String readLine(ByteBuffer buffer, String charset) throws LengthOverflowException
buffer
- charset
- LengthOverflowException
public static String readLine(ByteBuffer buffer, String charset, Integer maxlength) throws LengthOverflowException
buffer
- charset
- maxlength
- LengthOverflowException
public static String readString(ByteBuffer buffer, String charset, char endChar, Integer maxlength) throws LengthOverflowException
buffer
- charset
- endChar
- maxlength
- LengthOverflowException
public static String getUtf8(byte[] bytes)
bytes
- public static byte read(ByteBuffer buffer)
buffer
- public static short readShort(ByteBuffer buffer)
buffer
- public static int readUB1(ByteBuffer buffer)
public static int readUB2(ByteBuffer buffer)
public static int readUB2WithBigEdian(ByteBuffer buffer)
public static long readUB4(ByteBuffer buffer)
public static long readUB4WithBigEdian(ByteBuffer buffer)
public static final void writeUB2(ByteBuffer buffer, int i)
public static final void writeUB2WithBigEdian(ByteBuffer buffer, int i)
public static final void writeUB4(ByteBuffer buffer, long l)
public static final void writeUB4WithBigEdian(ByteBuffer buffer, long l)
Copyright © 2021. All rights reserved.