Here you can find the source of toHtml(String str)
public static String toHtml(String str)
//package com.java2s; public class Main { public static String toHtml(String str) { if (str == null) return ""; String html = new String(str); html = toHtmlInput(html);/*from w ww . j a v a 2 s . c o m*/ html = html.replaceAll("\r\n", "\n"); html = html.replaceAll("\n", "<br>\n"); html = html.replaceAll("\t", " "); html = html.replaceAll(" ", " "); return html; } public static String toHtmlInput(String str) { if (str == null) return ""; String html = new String(str); // html = html.replaceAll("&", "&"); html = html.replaceAll("<", "<"); html = html.replaceAll(">", ">"); // html = html.replaceAll("\"", """); return html; } }