Here you can find the source of htmlEscape(String html)
public static String htmlEscape(String html)
//package com.java2s; //License from project: Open Source License public class Main { public static String htmlEscape(String html) { String htmlEscaped = ""; for (int i = 0; i < html.length(); i++) { char c = html.charAt(i); if (c == '\n') { htmlEscaped += "<br>"; } else if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') { htmlEscaped += "&#" + ((int) c) + ';'; } else { htmlEscaped += c;/*from w w w.j a va2s .c o m*/ } } return htmlEscaped; } }