百度的都不好用,最后在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();
}