I have an URL like this:
localhost:8080/demo?xml=hello"<xyz>
";
here I want to decode <
and >


I have an URL like this:
localhost:8080/demo?xml=hello"<xyz>
";
here I want to decode <
and >


From apache Common -StringEscapeUtils#escapeHtml()
can simplify your job.
String string= StringEscapeUtils.unescapeHtml(encodedString);
First extract the part you want to decode:
String str = url.substring(str.indexOf('"') + 1, str.lastIndexOf('"'));
Then decode it using StringEscapeUtils.unescapeHtml4:
String result = StringEscapeUtils.unescapeHtml4(str);
I assume you are able to extract the String between quotes in the URL. Then you could use Apache Commons Lang (StringEscapeUtils.unescapeHtml4) to unescape special entities:
String unescapedString = StringEscapeUtils.unescapeHtml4("<xyz>
");
Use methods provided by Apache Commons Lang
import org.apache.commons.lang.StringEscapeUtils;
// ...
String afterDecoding = StringEscapeUtils.unescapeHtml(beforeDecoding);