Here you can find the source of htmlEncode(Object input)
public static String htmlEncode(Object input)
//package com.java2s; //License from project: Open Source License public class Main { public static String htmlEncode(Object input) { if (input == null) { return ""; }//from w w w.j a va2 s.com String strInput = input.toString().trim(); StringBuilder output = new StringBuilder(); int len = strInput.length(); char ch; for (int i = 0; i < len; i++) { ch = strInput.charAt(i); if (ch == '&') { output.append("&"); continue; } if (ch == '<') { output.append("<"); continue; } if (ch == '>') { output.append(">"); continue; } if (ch == '"') { output.append("""); } else { output.append(ch); } } return output.toString(); } }