public abstract class ByteUtil extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
ByteUtil.AssitRead
读帮助类
|
static class |
ByteUtil.AssitWrite
写帮助类
|
| 构造器和说明 |
|---|
ByteUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
and(byte[] data1,
byte[] data2)
字节与操作
|
static int |
byteshas0(byte[] bytes)
bytes含有0的个数
|
static int |
byteshas1(byte[] bytes)
bytes含有1的个数
|
static int |
byteshas1(int a) |
static byte[] |
concat(byte[] data1,
byte[] data2)
连接字节数组
|
static boolean |
equals(byte[] data1,
byte[] data2)
字节判断相等
|
static byte[] |
or(byte[] data1,
byte[] data2)
字节或操作
|
static int |
readInt(byte[] bytes,
boolean littleEndian)
虽然int占4个字节,但有一个符号位,如果要得到无符号的int,bytes最多只能为3,如果大于3字节,请用readLong
|
static int |
readIntB(byte[] bytes) |
static int |
readIntL(byte[] bytes) |
static int |
readIntL(byte[] bytes,
int offset,
int length) |
static int |
readIntSigned(byte[] bytes)
读带符号的整形
|
static long |
readLong(byte[] bytes,
boolean littleEndian)
读无符号的long
|
static long |
readLongB(byte[] bytes) |
static long |
readLongL(byte[] bytes) |
static long |
readLongL(byte[] bytes,
int offset,
int length) |
long |
readLongSigned(byte[] bytes)
读带符号的Long
|
static String |
readString(byte[] bytes)
通过字节读字符串
|
static String |
readString(byte[] bytes,
int offset,
int length)
读取字节中的字符串
|
static byte[][] |
splitBytes(byte[] data,
int maxLength)
把data分隔成每行最多maxLength列的多行数组
|
static byte[] |
toBigEndian(byte[] value)
小字节序转为大字节序
|
static byte[] |
toByteArray(byte num)
转为字节数组
|
static byte[] |
toByteArray(int num)
int转为字节数组
|
static byte[] |
toByteArray(long num)
long转为字节数组
|
static byte[] |
toByteArray(short num)
short转为字节数组
|
static int |
toUnsigned(byte b)
得到无符号int
|
static long |
toUnsigned(int i)
得到无符号long
|
static int |
toUnsigned(short s)
得到无符号int
|
static byte[] |
trunc00(byte[] bytes)
把前后的00二进制去掉进,要求中间不出现00
|
static byte[] |
xor(byte[] data1,
byte[] data2)
字节异或操作
|
public static byte[] toBigEndian(byte[] value)
value - 小端字节public static int toUnsigned(byte b)
b - 字节public static int toUnsigned(short s)
s - short参数public static long toUnsigned(int i)
i - int参数public static long readLong(byte[] bytes,
boolean littleEndian)
bytes - 原始字节数组littleEndian - 是否小端字节,true:小端字节 false:大端字节public static long readLongL(byte[] bytes)
public static long readLongL(byte[] bytes,
int offset,
int length)
public static long readLongB(byte[] bytes)
public long readLongSigned(byte[] bytes)
bytes - 原始字节数组public static int byteshas1(byte[] bytes)
bytes - 原始字节数组public static int byteshas1(int a)
public static int byteshas0(byte[] bytes)
bytes - 原始字节数组public static int readInt(byte[] bytes,
boolean littleEndian)
bytes - 要转的字节数组littleEndian - 是否小字节序public static int readIntL(byte[] bytes)
public static int readIntL(byte[] bytes,
int offset,
int length)
public static int readIntB(byte[] bytes)
public static int readIntSigned(byte[] bytes)
bytes - 原始字节数组public static String readString(byte[] bytes)
bytes - 原始字节数组public static byte[] trunc00(byte[] bytes)
bytes - 原始字节数组public static String readString(byte[] bytes, int offset, int length)
bytes - 原始字节数组offset - 起始位置length - 处理长度public static byte[] toByteArray(byte num)
num - 单个字节public static byte[] toByteArray(short num)
num - shortpublic static byte[] toByteArray(int num)
num - intpublic static byte[] toByteArray(long num)
num - longpublic static byte[][] splitBytes(byte[] data,
int maxLength)
data - 要分隔的数据源maxLength - 每行最多列public static byte[] or(byte[] data1,
byte[] data2)
data1 - 字节1data2 - 字节2public static byte[] and(byte[] data1,
byte[] data2)
data1 - 字节1data2 - 字节2public static byte[] xor(byte[] data1,
byte[] data2)
data1 - 字节1data2 - 字节2public static boolean equals(byte[] data1,
byte[] data2)
data1 - 字节1data2 - 字节2public static byte[] concat(byte[] data1,
byte[] data2)
data1 - 字节1data2 - 字节2Copyright © 2017. All rights reserved.