Here you can find the source of htmlEscape(String text)
public static String htmlEscape(String text)
//package com.java2s; //License from project: CDDL license public class Main { /**//from w w w . j a va2s .co m * Performs necessary escaping to render arbitrary plain text as plain text without any markup. */ public static String htmlEscape(String text) { StringBuilder buf = new StringBuilder(text.length() + 64); for (int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if (ch == '<') buf.append("<"); else if (ch == '&') buf.append("&"); else buf.append(ch); } return buf.toString(); } }