-4

I have a string in java that looks like this "&#039;&#039;&#039;&#039;&lt;&gt;!@#$%^&amp", this was escaped in javascript. I need to obtain the original string before escaping the special characters, which is "''''<>!@#$%^&*()".

Matt Ball
  • 354,903
  • 100
  • 647
  • 710

3 Answers3

1

You can use StringEscapeUtils.unescapeHtml4 for this.

For example, the string "&lt;Fran&ccedil;ais&gt;" will become "<Français>"

pascalhein
  • 5,700
  • 4
  • 31
  • 44
0

You need to know how it was encoded to reverse it.

If it was URL encoded (which looks likely) then Java has a built in URLDecoder class.

URLDecoder.decode(message, encoding);
Tim B
  • 40,716
  • 16
  • 83
  • 128
0

Apache Commons provides utilities for this.

org.apache.commons.lang.StringEscapeUtils.unescapeHtml(String string) should be what you want.

Check out the API here

Dragondraikk
  • 1,659
  • 11
  • 21