Java tutorial
//package com.java2s; public class Main { public static String encode(String str) { if (str == null) { return null; } str = str.replaceAll(">", ">"); str = str.replaceAll("<", "<"); str = str.replaceAll("\"", """); str = str.replaceAll("&", "&"); return str; } }