Here you can find the source of filterHTML(String input)
public static String filterHTML(String input)
//package com.java2s; //License from project: Open Source License public class Main { public static String filterHTML(String input) { String result = (input == null ? "" : input); if (input != null && input.length() > 0) { StringBuffer filtered = new StringBuffer(input.length()); char c; for (int i = 0; i < input.length(); i++) { c = input.charAt(i);// w w w . j a v a2 s .co m String s = null; switch (c) { case '<': s = "<"; break; case '>': s = ">"; break; case ' ': try { if (input.charAt(i + 1) == ' ') s = " "; } catch (Exception e) { } //s=" "; break; /* case '"': s="""; break; case '&': s="&"; break;*/ } if (s != null) filtered.append(s); else filtered.append(c); } result = filtered.substring(0); //System.out.println("filterHTML-> input="+input+" result="+result); } return result; } }