/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
// "Happy & Sad" in HTML form.
String s = "Happy & Sad";
System.out.println(s);
try {
// Change to "Happy & Sad". DOESN'T WORK!
s = java.net.URLDecoder.decode(s, "UTF-8");
System.out.println(s);
} catch (UnsupportedEncodingException ex) {
}
}
Jakarta Commons Lang library's StringEscapeUtils.escapeHtml() and unescapeHtml() methods are what you are looking for. See http://commons.apache.org/lang/api-2.6/org/apache/commons/lang/StringEscapeUtils.html.