Here you can find the source of htmlEscape(String str)
public static String htmlEscape(String str)
//package com.java2s; //License from project: Open Source License public class Main { public static String htmlEscape(String str) { StringBuilder esc = new StringBuilder(); for (int i = 0; i < str.length(); ++i) { final char c = str.charAt(i); switch (c) { case '<': esc.append("<"); break; case '>': esc.append(">"); break; case '&': esc.append("&"); break; case '"': esc.append("""); break; default: esc.append(c);/*from w w w.ja va 2 s.c om*/ } } return esc.toString(); } }