/*
Are you for real?
What\'s in a name?
Mc''Williams
<data>
<data>
*/
import org.apache.commons.lang.StringEscapeUtils;
public class StringUtilsEscapeExampleV1 {
public static void main(String args[]) {
String unescapedJava = "Are you for real?";
System.err.println(
StringEscapeUtils.escapeJava(unescapedJava));
String unescapedJavaScript = "What's in a name?";
System.err.println(
StringEscapeUtils.escapeJavaScript(unescapedJavaScript));
String unescapedSql = "Mc'Williams";
System.err.println(
StringEscapeUtils.escapeSql(unescapedSql));
String unescapedXML = "<data>";
System.err.println(
StringEscapeUtils.escapeXml(unescapedXML));
String unescapedHTML = "<data>";
System.err.println(
StringEscapeUtils.escapeHtml(unescapedHTML));
}
}
|