Android hex十六进制转String

百度的都不好用,最后在stackoverflow上找到了。。。
https://stackoverflow.com/questions/12039341/hex-to-string-in-java-performance-is-too-slow

    public static String hexToString(String hex) {
        StringBuilder sb = new StringBuilder();
        for (int count = 0; count < hex.length() - 1; count += 2) {
            String output = hex.substring(count, (count + 2));    //grab the hex in pairs
            int decimal = Integer.parseInt(output, 16);    //convert hex to decimal
            sb.append((char) decimal);    //convert the decimal to character
        }
        return sb.toString();
    }
图片.png
Android hex十六进制转String_第1张图片
图片.png

你可能感兴趣的:(Android hex十六进制转String)