删除一部分Hexa消息以获得好消息

时间:2017-05-04 11:24:11

标签: java xml string del

我尝试使用此方法将Hex of char字符串转换为String:

public String HexToString(String inputString){
    StringBuilder output = new StringBuilder();
    for (int i = 0; i < inputString.length(); i+=2) {
        String str = inputString.substring(i, i+2);
        output.append((char)Integer.parseInt(str, 16));
    }
    return output.toString();
}

输入是:

  

“4d442020000000020000000000000008ffffffff000000000000022200 0001b54d514852463220 20000000000000000141 4d5120434d504c4c3333 2020202020d75db05811 51d02000000000000000 00000000000000000000 00000000000000000000 00202020202020202020 20202020202020202020 20202020202020202020 20202020202020202020 20202020202020202043 20202020202020202020 4d504c4c333320202020 20000000000000000000 00000000020202020202 02020202020202020202 02020202020202020202 02020202020200000001 c7765626c6f6 ....”

此方法有效,但我的消息包含奇怪的字符的问题。 转换后,我在标题中收到了这个字符:“μMQHRF2”

问题是如何删除此标题?当消息在Hexa上或转换后我应该这样做吗?以及如何从字符串中删除此字符?

1 个答案:

答案 0 :(得分:0)