类 ByteUtils
java.lang.Object
com.walker.tcp.util.ByteUtils
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static StringbytesToHexString(byte[] src) Convert byte[] to hex string.static StringbytesToHexString(byte[] src, int begin, int len) Convert byte[] to hex string.static StringbytesToHexString2(byte[] src) 空格分隔static String[]bytesToHexStrings(byte[] src) Convert byte[] to hex string[].static StringbyteToHexString(byte src) static intdelH(int val) 去除int最高位static StringgetCommand(byte[] cmdArea) 返回命令字符串,如:106static intgetHeight4(byte data) 获取高四位static intgetLow4(byte data) 获取低四位static StringgetMsgCmd(byte[] msg) 获取接收到的信息中的指令码static byte[]hexStringToBytes(String hexString) Convert hex string to byte[] 把字符串转化为字节数组static Stringint2HexString(int src) 将 10进制int 转换为占一个字节的hexStringstatic StringintTo4HexString(int src) 将10进制int转换为占4个字节的hexStringstatic byte[]intToBytes(int num) int -> byte[4] 低位在前static StringintToHexString(int src) 将10进制int转换为占2个字节的hexString(低字节在前)static StringintToHexStringH(int src) 将10进制int转换为占2个字节的hexString(高字节在前)static String将i进制字符串转换成j进制字符串static voidstatic StringtoBinary(byte b) 2进制static byte[]toByteArray(int iSource, int iArrayLen) int -> byte[iArrayLen]static byte[]toBytes(int v) int -> byte[2]static byte[]toBytesH(int v) int -> byte[2]static doubletoDouble(byte[] res, int begainIdx) 低位在前 的 byte[2] 转 int, int*0.01转成double并保留两位小数static StringtoHexString(byte[] byteArray) 字节数组转成16进制表示格式的字符串static StringtoHexString(String src) 将10进制String 转换为占2个字节的hexString(低位在前)static inttoInt2(byte[] res) byte[] 转 intstatic inttoInt2(byte[] res, int begainIdx) 低位在前 的 byte[2] 转 intstatic inttoInt3(byte[] bs, int begain) 低位在前 ,3位的byte[] 转 intstatic inttoInt4(byte[] bs) 低位在前 ,4位的byte 转 intstatic inttoInt4(byte[] bs, int pos) 将低位在前 ,4位的byte 转 intstatic inttoIntByH(byte[] bs, int start) 获取 高位在前的4位byte int值
-
构造器详细资料
-
ByteUtils
public ByteUtils()
-
-
方法详细资料
-
toBinary
2进制- 参数:
b-- 返回:
-
getHeight4
public static int getHeight4(byte data) 获取高四位- 参数:
data-- 返回:
-
getLow4
public static int getLow4(byte data) 获取低四位- 参数:
data-- 返回:
-
delH
public static int delH(int val) 去除int最高位- 参数:
val-- 返回:
-
byteToHexString
-
bytesToHexString
Convert byte[] to hex string. 把字节数组转化为字符串- 参数:
src-begin- byte[] 起始位置len- 长度- 返回:
-
bytesToHexString
Convert byte[] to hex string. 把字节数组转化为字符串- 参数:
src- byte[]- 返回:
- hex string
-
bytesToHexString2
空格分隔- 参数:
src-- 返回:
-
toHexString
字节数组转成16进制表示格式的字符串- 参数:
byteArray- 需要转换的字节数组- 返回:
- 16进制表示格式的字符串
-
bytesToHexStrings
Convert byte[] to hex string[]. 把字节数组转化为字符串数组 -
hexStringToBytes
Convert hex string to byte[] 把字符串转化为字节数组- 参数:
hexString- the hex string, 两位string一个byte, 允许有空格分隔- 返回:
- byte[]
-
int2HexString
将 10进制int 转换为占一个字节的hexString- 参数:
src-- 返回:
-
intToHexString
将10进制int转换为占2个字节的hexString(低字节在前)- 参数:
src-- 返回:
-
intToHexStringH
将10进制int转换为占2个字节的hexString(高字节在前)- 参数:
src-- 返回:
-
toHexString
将10进制String 转换为占2个字节的hexString(低位在前)- 参数:
src-- 返回:
-
intTo4HexString
将10进制int转换为占4个字节的hexString- 参数:
src-- 返回:
-
toByteArray
public static byte[] toByteArray(int iSource, int iArrayLen) int -> byte[iArrayLen]- 参数:
iSource-iArrayLen- invalid input: '<'=4- 返回:
-
toBytes
public static byte[] toBytes(int v) int -> byte[2]- 返回:
- 低位在前
-
toBytesH
public static byte[] toBytesH(int v) int -> byte[2]- 返回:
- 高位在前
-
intToBytes
public static byte[] intToBytes(int num) int -> byte[4] 低位在前- 参数:
num-- 返回:
-
toInt3
public static int toInt3(byte[] bs, int begain) 低位在前 ,3位的byte[] 转 int- 返回:
-
toInt4
public static int toInt4(byte[] bs) 低位在前 ,4位的byte 转 int- 参数:
bs- 低位在前 byte数组- 返回:
-
toIntByH
public static int toIntByH(byte[] bs, int start) 获取 高位在前的4位byte int值- 参数:
bs- 高位在前 byte数组- 返回:
-
toInt4
public static int toInt4(byte[] bs, int pos) 将低位在前 ,4位的byte 转 int- 参数:
bs- byte数组pos- 起始位置- 返回:
-
toDouble
public static double toDouble(byte[] res, int begainIdx) 低位在前 的 byte[2] 转 int, int*0.01转成double并保留两位小数- 参数:
res-begainIdx- 起始位置- 返回:
-
toInt2
public static int toInt2(byte[] res, int begainIdx) 低位在前 的 byte[2] 转 int- 参数:
res-begainIdx- 起始位置- 返回:
-
toInt2
public static int toInt2(byte[] res) byte[] 转 int- 参数:
res- 低位在前 ,2位的byte数组- 返回:
-
getMsgCmd
获取接收到的信息中的指令码- 参数:
msg- 接收到的信息- 返回:
-
getCommand
返回命令字符串,如:106- 参数:
cmdArea-- 返回:
-
itoj
将i进制字符串转换成j进制字符串- 参数:
str-i-j-
-
main
-