public class Buffers extends Object
| Modifier and Type | Method and Description |
|---|---|
static ByteBuffer |
copy(ByteBuffer src,
ByteBuffer dest)
拷贝 ByteBuffer
|
static ByteBuffer |
copy(ByteBuffer src,
ByteBuffer dest,
int length)
拷贝 ByteBuffer
|
static ByteBuffer |
copy(ByteBuffer src,
int srcStart,
ByteBuffer dest,
int destStart,
int length)
拷贝 ByteBuffer
|
static ByteBuffer |
copy(ByteBuffer src,
int start,
int end)
拷贝到一个新的 ByteBuffer
|
static ByteBuffer |
create(byte[] data)
创建新 Buffer
|
static ByteBuffer |
create(String data)
从字符串创建新 Buffer
|
static int |
lineEnd(ByteBuffer buffer)
一行的末尾位置 查找位置时位移 ByteBuffer 到结束位置
|
static int |
lineEnd(ByteBuffer buffer,
int maxLength)
一行的末尾位置 查找位置时位移 ByteBuffer 到结束位置
|
static byte[] |
readBytes(ByteBuffer buffer)
读取剩余部分 bytes
|
static byte[] |
readBytes(ByteBuffer buffer,
int maxLength)
读取指定长度的 bytes
如果长度不足则读取剩余部分 此时buffer必须为读模式 |
static byte[] |
readBytes(ByteBuffer buffer,
int start,
int end)
读取指定区间的数据
|
static String |
readLine(ByteBuffer buffer)
读取一行 如果 buffer 中最后一部分并非完整一行则返回 null
|
static String |
readStr(ByteBuffer buffer)
读取剩余部分并转为字符串
|
public static ByteBuffer copy(ByteBuffer src, int start, int end)
src - 源start - 起始位置 包括end - 结束位置 不包括public static ByteBuffer copy(ByteBuffer src, ByteBuffer dest)
src - 源dest - 目标public static ByteBuffer copy(ByteBuffer src, ByteBuffer dest, int length)
src - 源dest - 目标length - 长度public static ByteBuffer copy(ByteBuffer src, int srcStart, ByteBuffer dest, int destStart, int length)
src - 源srcStart - 源开始的位置dest - 目标destStart - 目标开始的位置length - 长度public static String readStr(ByteBuffer buffer)
buffer - ByteBufferpublic static byte[] readBytes(ByteBuffer buffer)
buffer - ByteBufferpublic static byte[] readBytes(ByteBuffer buffer, int maxLength)
buffer - ByteBuffermaxLength - 最大长度public static byte[] readBytes(ByteBuffer buffer, int start, int end)
buffer - bufferstart - 开始位置end - 结束位置public static int lineEnd(ByteBuffer buffer)
buffer - ByteBufferpublic static int lineEnd(ByteBuffer buffer, int maxLength)
buffer - ByteBuffermaxLength - 读取最大长度public static String readLine(ByteBuffer buffer)
buffer - ByteBufferpublic static ByteBuffer create(byte[] data)
data - 数据public static ByteBuffer create(String data)
data - 数据Copyright © 2025. All rights reserved.