Possible Duplicate:
Convert a string representation of a hex dump to a byte array using Java?
For example I get an octet string as follow:
3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d38223f3e3c53
6f6170456e763a456e76656c6f706520786d6c6e733a536f6170456e763d22687474703a2f2f7363
68656d61732e786d6c736f61702e6f72672f736f61702f656e76656c6f70652f223e3c536f617045
6e763a48656164657220786d6c6e733a7773613d22687474703a2f2f7777772e77332e6f72672f32
3030352f30382f61646472657373696e67223e3c7773613a46726f6d3e3c7773613a416464726573
733e43484e594442473c2f7773613a416464726573733e3c2f7773613a46726f6d3e3c7773613a54
6f3e434352433c2f7773613a546f3e3c7773613a416374696f6e3e687474703a2f2f636372632e73
6572766963652e62616e6b636f6d6d2e636f6d2f6162737472616374696f6e2f61746f6d69632f74
6563686e6963616c2e506572736f6e616c4372656469745265706f7274536572762f4661756c743c
2f7773613a416374696f6e3e3c7773613a4d65737361676549443e75726e3a757569643a30303031
And I know the underlying text is UTF-8 encoding, so who can offer some methods to convert these octets to readable string?
Try reading each two characters, parsing them as a base 16 integer with
Integer.parseInt(String,int), adding them to a byte array, and constructing aStringfrom the result:Your string example looks like an XML document containing a SOAP message.