Here you can find the source of toHtml(String value, String defaultValue)
public static String toHtml(String value, String defaultValue)
//package com.java2s; //License from project: LGPL public class Main { public static String toHtml(String value, String defaultValue) { if (value == null) return defaultValue; StringBuffer result = new StringBuffer(value.length()); char ch = ' '; for (int i = 0; i < value.length(); i++) { switch (ch = value.charAt(i)) { case '<': result.append("<"); break; case '>': result.append(">"); break; case '&': result.append("&"); break; case '\'': result.append("'"); break; case '"': result.append("""); break; default: result.append(ch);/*w ww . j a v a2 s . c om*/ } } return result.toString(); } public static String toHtml(String value) { return toHtml(value, ""); } }