字节数组转十六进制字符串
作者:
Matures | 来源:发表于
2019-12-09 14:28 被阅读0次public static String bytesToHex(byte[] bytes, int counts) {
if (bytes == null) {
return null;
}
StringBuffer sbu = new StringBuffer();
for (int i = 0; i < counts/* bytes.length */; i++) {
int val = new Byte(bytes[i]).intValue();
String str = Integer.toHexString(val & 0xff);
if (str.length() == 1) {
str = "0" + str;
}
sbu.append(str);
if (i != counts - 1) {
sbu.append(" ");
}
}
return sbu.toString().toUpperCase();
}
本文标题:字节数组转十六进制字符串
本文链接:https://www.haomeiwen.com/subject/ngbbgctx.html
网友评论