byte数组转换成十六进制(bytesToHexString)

 
  
/* byte数组转换成十六进制输出:"abcd" => "61626364" */
public String bytesToHexString(byte[] bArr) {
    StringBuffer sb = new StringBuffer(bArr.length);
    String sTmp;

    for (int i = 0; i < bArr.length; i++) {
        sTmp = Integer.toHexString(0xFF & bArr[i]);
        if (sTmp.length() < 2)
            sb.append(0);
        sb.append(sTmp.toUpperCase());
    }

    return sb.toString();
}

你可能感兴趣的:(开发)