Java by API/org.apache.commons.lang/StringEscapeUtils
StringEscapeUtils: escapeHtml(String arg0)
/*
Escaped HTML >>> <p>MyName<p>
UnEscaped HTML >>> <p>MyName<p>
*/
import org.apache.rumons.lang.StringEscapeUtils;
public class StringEscapeUtilsTrial {
public static void main(String[] args) {
String strHTMLInput = "<p>MyName<p>";
String strEscapeHTML = StringEscapeUtils.escapeHtml(strHTMLInput);
String strUnEscapeHTML = StringEscapeUtils.unescapeHtml(strEscapeHTML);
System.out.println("Escaped HTML >>> " + strEscapeHTML);
System.out.println("UnEscaped HTML >>> " + strUnEscapeHTML);
}
}
StringEscapeUtils: unescapeHtml(String str)
/*
Escaped HTML >>> <p>MyName<p>
UnEscaped HTML >>> <p>MyName<p>
*/
import org.apache.rumons.lang.StringEscapeUtils;
public class StringEscapeUtilsTrial {
public static void main(String[] args) {
String strHTMLInput = "<p>MyName<p>";
String strEscapeHTML = StringEscapeUtils.escapeHtml(strHTMLInput);
String strUnEscapeHTML = StringEscapeUtils.unescapeHtml(strEscapeHTML);
System.out.println("Escaped HTML >>> " + strEscapeHTML);
System.out.println("UnEscaped HTML >>> " + strUnEscapeHTML);
}
}