Here you can find the source of toHtmlString(String src, boolean noSingleQuotes)
public static String toHtmlString(String src, boolean noSingleQuotes)
//package com.java2s; //License from project: LGPL import java.text.CharacterIterator; import java.text.StringCharacterIterator; public class Main { public static String toHtmlString(String src, boolean noSingleQuotes) { StringCharacterIterator iter = new StringCharacterIterator(src); StringBuffer buf = new StringBuffer(); for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) { switch (c) { case '\'': if (noSingleQuotes) { buf.append(c);/*ww w. j av a 2s . c o m*/ } else { //buf.append("'"); buf.append("'"); } break; case '\"': buf.append("""); break; case '<': buf.append("<"); break; case '>': buf.append(">"); break; case '&': buf.append("&"); break; default: buf.append(c); } } return buf.toString(); } }