Write code to replace Escape Sequence
& becomes &...
Check null input value
Use String.replace() to replace value, one by one
//package com.book2s; public class Main { public static void main(String[] argv) { String input = "&"; System.out.println(replaceEscapeSequence(input)); }//from w w w.j av a 2 s . c o m public static String replaceEscapeSequence(String input) { String output = null; if (input != null) { output = input.replaceAll("<", "<"); output = output.replaceAll(">", ">"); output = output.replaceAll("&", "&"); output = output.replaceAll("'", "??"); output = output.replaceAll(""", "\""); } return output; } }