public class Bytes extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Bytes.Pool
字节数组池化
|
| 限定符和类型 | 字段和说明 |
|---|---|
static byte[] |
_nilBytes |
protected byte[] |
m_Bytes
存储内容的字节数组
|
protected int |
m_Offset
内容在数组中的开始位置
|
protected int |
m_Size
内容的字节数
|
static int |
POOL_1K_SIZE |
static int |
POOL_512_SIZE |
static int |
POOL_8K_SIZE |
static int |
REMAIN_XB |
static int |
UNIT_GB |
static int |
UNIT_KB |
static int |
UNIT_MB |
static long |
UNIT_TB |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
compare(byte[] b1,
int offset1,
byte[] b2,
int offset2,
int length)
比较两个字节数组
|
static Bytes |
empty()
0长度字节数组
|
byte[] |
fit()
取得刚好合适内容的字节数组
|
static String |
formatHumanReadable(long bytes)
友好的存储容量格式化,按T、G、K及保留小数点两位,如:4.5T,3.4G,2.3M,1.2K
|
static StringBuilder |
formatHumanReadable(StringBuilder sb,
long bytes)
友好的存储容量格式化,按T、G、K及保留小数点两位,如:4.5T,3.4G,2.3M,1.2K
|
byte[] |
getBytes() |
int |
getFree()
剩余空间(数组长度-size)
|
int |
getOffset() |
int |
getSize() |
static long |
parseHumanReadable(String readable)
从格式化友好的存储容量(如1.5G,200M)中解析出实际字节数大小
|
static Bytes.Pool |
pool(int capacity)
找一个容量合适的池
|
void |
setSize(int size) |
String |
toString() |
static StringBuilder |
toString(StringBuilder sb,
byte[] bytes,
int limit)
字串数组格式串
|
protected final byte[] m_Bytes
protected int m_Offset
protected int m_Size
public static final byte[] _nilBytes
public static final long UNIT_TB
public static final int UNIT_GB
public static final int UNIT_MB
public static final int UNIT_KB
public static final int REMAIN_XB
public static int POOL_8K_SIZE
public static int POOL_1K_SIZE
public static int POOL_512_SIZE
public byte[] getBytes()
public int getOffset()
public int getSize()
public byte[] fit()
public int getFree()
public void setSize(int size)
public static StringBuilder toString(StringBuilder sb, byte[] bytes, int limit)
sb - 输出格式串的StringBuilder,若为null则内部创建bytes - 字节数组limit - 限制节字数(-1为不限制)public static Bytes empty()
public static int compare(byte[] b1,
int offset1,
byte[] b2,
int offset2,
int length)
b1 - 字节数组1offset1 - 字节数组1开始位置b2 - 字节数组2offset2 - 字节数组2开始位置length - 长度public static String formatHumanReadable(long bytes)
bytes - 字节数public static StringBuilder formatHumanReadable(StringBuilder sb, long bytes)
sb - 字串缓冲区bytes - 字节数public static long parseHumanReadable(String readable) throws NumberFormatException
readable - 友好的存储容量NumberFormatException - 字符串格式错误public static Bytes.Pool pool(int capacity)
capacity - 期望的容量Copyright © 2021. All rights reserved.