Here you can find the source of htmlEncode(String txt)
public static String htmlEncode(String txt)
//package com.java2s; public class Main { /**//from ww w.j av a 2s. co m * Encodes the given text to HTML save form. */ public static String htmlEncode(String txt) { if (txt == null) { return ""; } return txt.replace("&", "&").replace("<", "<").replace(">", ">").replace("\"", """) .replace("'", "'").replace("\r\n", "<br/>").replace("\n", "<br/>"); } }