本文介绍了如何将十六进制字符串转换为Java字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为了记录目的,一些其他人将日志转换为字节数组,然后转换为十六进制字符串。但是我想把它恢复到java String中,但是不能这样做,
For logging purpose some other guys converting the logs to byte array and then to hex string. But I want to get it back in java String, but not able to do so,
日志文件中的十六进制字符串看起来像
the hex string in log file looks something like
fd00000aa8660b5b010006acdc0100000101000100010000
有人可以帮忙解码它?
在此先感谢。
推荐答案
使用在Apache Commons:
Using Hex in Apache Commons:
String hexString = "fd00000aa8660b5b010006acdc0100000101000100010000"; byte[] bytes = Hex.decodeHex(hexString.toCharArray()); System.out.println(new String(bytes, "UTF-8"));
这篇关于如何将十六进制字符串转换为Java字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!