Java HTML Escape htmlUnescape(String safeHtml)

Here you can find the source of htmlUnescape(String safeHtml)

Description

html Unescape

License

Open Source License

Declaration

public static String htmlUnescape(String safeHtml) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String htmlUnescape(String safeHtml) {
        if (safeHtml == null)
            return null;

        if (safeHtml.indexOf("<") != -1) {
            safeHtml = safeHtml.replace("&lt;", "<");
        }/*from   ww w .j  a  v  a 2s.c o  m*/
        if (safeHtml.indexOf("&gt;") != -1) {
            safeHtml = safeHtml.replace("&gt;", ">");
        }
        if (safeHtml.indexOf("&quot;") != -1) {
            safeHtml = safeHtml.replace("&quot;", "\"");
        }
        if (safeHtml.indexOf("&#39;") != -1) {
            safeHtml = safeHtml.replace("&#39;", "'");
        }
        if (safeHtml.indexOf("&amp;") != -1) {
            safeHtml = safeHtml.replace("&amp;", "&");
        }
        return safeHtml;
    }
}

Related

  1. htmlEscape(String text)
  2. htmlescapeAll(String s1)
  3. htmlEscapeBasicMarkup(final String text)
  4. HTMLEscapeBr(String original)
  5. htmlEscapeSpace(String uri)