Java - Write code to replace Escape Sequence

Requirements

Write code to replace Escape Sequence

& becomes &...

Hint

Check null input value

Use String.replace() to replace value, one by one

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String input = "&";
        System.out.println(replaceEscapeSequence(input));
    }/*from w  w w  .  j  a v  a  2s  .  co  m*/

    public static String replaceEscapeSequence(String input) {
        String output = null;
        if (input != null) {
            output = input.replaceAll("&lt;", "<");
            output = output.replaceAll("&gt;", ">");
            output = output.replaceAll("&amp;", "&");
            output = output.replaceAll("&apos;", "??");
            output = output.replaceAll("&quot;", "\"");
        }
        return output;
    }
}

Related Exercise