public class ByteUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static byte[] |
EMPTY_BYTES |
| 构造器和说明 |
|---|
ByteUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
length(String hex)
获取HEX 的字节长度
|
static String |
toAscii(byte... bs)
byte 数组转 Ascii
|
static String |
toBinary(byte... bs)
转换二进制字符串
|
static byte[] |
toByte(int i)
int -> byte[]
|
static byte[] |
toByte(int i,
int bs)
int -> byte[] (指定byte数组长度)
|
static byte[] |
toByte(long i,
int bs)
long -> byte[] (指定byte数组长度)
|
static byte[] |
toByte(String hex)
hex -> byte[]
|
static byte[] |
toByte(String hex,
int length)
hex -> byte[] (指定byte数组长度)
|
static int |
toCRC(int regInit,
int polynomial,
byte[] bytes)
CRC生成
|
static int |
toCRC0(int regInit,
int polynomial,
byte[] bytes)
CRC生成
|
static float |
toFloat(byte... bs)
byte[] -> float
|
static String |
toHex(byte... bytes)
byte[] -> hex
|
static String |
toHex(byte b)
byte -> hex
|
static String |
toHex(int i)
int -> hex
|
static String |
toHex(int i,
int bs)
int -> hex (指定长度)
|
static String |
toHex(String hex)
HEX 优化,默认长度为2的倍数
|
static int |
toInt(byte... bs)
byte[] -> int
|
static int |
toInt(byte b)
byte -> int
|
static int |
toInt(String hex)
hex -> int
|
public static String toHex(byte b)
b - byte srcpublic static String toHex(byte... bytes)
bytes - byte array srcpublic static String toHex(int i)
i - int srcpublic static String toHex(int i, int bs)
i - int srcbs - return bytes lengthpublic static String toHex(String hex)
hex - String's Srcpublic static byte[] toByte(String hex)
hex - hex's stringpublic static byte[] toByte(String hex, int length)
hex - hex's stringlength - return byte array lengthpublic static byte[] toByte(int i)
i - int srcpublic static byte[] toByte(int i,
int bs)
i - int srcbs - byte array lengthpublic static byte[] toByte(long i,
int bs)
i - long srcbs - byte array lengthpublic static int toInt(byte b)
b - byte srcpublic static int toInt(byte... bs)
bs - bytespublic static float toFloat(byte... bs)
bs - bytespublic static String toAscii(byte... bs)
bs - bytespublic static int toInt(String hex)
hex - hex's stringpublic static int toCRC0(int regInit,
int polynomial,
byte[] bytes)
regInit - 初始值polynomial - 多项式bytes - 待校验数组public static int toCRC(int regInit,
int polynomial,
byte[] bytes)
regInit - 初始值polynomial - 多项式(需要反转)bytes - 待校验数组public static String toBinary(byte... bs)
bs - bytes srcpublic static int length(String hex)
hex - hex's stringCopyright © 2019. All rights reserved.