字节数组转16进制字符串

 /*
* 字节数组转16进制字符串
*/
public static String bytes2HexString(byte[] b) {
String r = "";

for (int i = 0; i < b.length; i++) {
String hex = Integer.toHexString(b[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
r += hex.toUpperCase() + " ";
}

return r;
}
posted @ 2017-07-31 09:35  Jokeyyu  阅读(275)  评论(0编辑  收藏  举报