Here you can find the source of toHTMLString(String in)
public static String toHTMLString(String in)
//package com.java2s; //License from project: Open Source License public class Main { public static String toHTMLString(String in) { if (in == null || in.length() <= 0) { return ""; }/* ww w . j av a2 s. com*/ StringBuffer out = new StringBuffer(); for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); if (c == '\'') out.append("'"); else if (c == '\"') out.append(""); else if (c == '<') out.append("<"); else if (c == '>') out.append(">"); else if (c == '&') out.append("&"); else if (c == ' ') out.append(" "); else if (c == '\n') out.append("<br>"); else if (c == '\r') continue; else out.append(c); } return out.toString(); } }