Java tutorial
//package com.java2s; //License from project: Apache License public class Main { /** * escape characters like <, &, > * @param text * @return */ public static String encodeString(String text) { String ret = null; ret = text.replaceAll("&", "&"); ret = ret.replaceAll("<", "<"); ret = ret.replaceAll(">", ">"); ret = ret.replaceAll("'", "'"); ret = ret.replaceAll("\"", """); return ret; } }