Here you can find the source of quoteForHTML(String toQuote)
public static String quoteForHTML(String toQuote)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. ja v a 2 s . co m * Quotes each and every character, e.g. '!' as !. Used for verbatim * display of arbitrary strings that may contain HTML entities. */ public static String quoteForHTML(String toQuote) { StringBuilder result = new StringBuilder(); for (int i = 0; i < toQuote.length(); ++i) { result.append("&#").append((int) toQuote.charAt(i)).append(';'); } return result.toString(); } }