例如:564E3A312D302E302E30 可转换为:VN:1-0.0.0
/**
* The conversion of 16 to ASCII
* @other > Integer.toHexString(int) -> 10 to 16
* @param hex
* @return
*/
public static String convertHexToString(String hex) {
StringBuilder sb = new StringBuilder();
StringBuilder temp = new StringBuilder();
// 564e3a322d302e312e34 split into two characters 56, 4e, 3a...
for (int i = 0; i < hex.length() - 1; i += 2) {
// grab the hex in pairs
String output = hex.substring(i, (i + 2));
// convert hex to decimal
int decimal = Integer.parseInt(output, 16);
// convert the decimal to character
sb.append((char) decimal);
temp.append(decimal);
}
// System.out.println(sb.toString());
return sb.toString();
}