Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * Escapes special HTML entities * @param text * @return text with HTML entities escaped */ public static String escapeXMLEntities(String text) { if (text == null) return null; text = text.replace("&", "&"); text = text.replace("\"", """); text = text.replace("<", "<"); text = text.replace(">", ">"); text = text.replace("'", "'"); return text; } }