Java HTML Escape htmlEscape(String input)

Here you can find the source of htmlEscape(String input)

Description

Escape the HTML specific characters (like <) but keeps the UTF-8 content (for characters like é).

License

Open Source License

Declaration

public static String htmlEscape(String input) 

Method Source Code

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

public class Main {
    /**//from  www. j  a  va 2s .  c  o  m
     * Escape the HTML specific characters (like &lt;) but keeps the UTF-8 content (for characters like &eacute;).
     */
    public static String htmlEscape(String input) {
        if (input == null) {
            return null;
        }
        String result = input.replace("&", "&amp;");
        result = result.replace("<", "&lt;");
        result = result.replace(">", "&gt;");
        result = result.replace("\"", "&quot;");
        return result;
    }
}

Related

  1. htmlEscape(String html)
  2. htmlescape(String html)
  3. htmlEscape(String input)
  4. htmlEscape(String input)
  5. htmlEscape(String input)
  6. htmlEscape(String nonHTMLsrc)
  7. htmlEscape(String s)
  8. htmlEscape(String S)
  9. htmlEscape(String s)