Java HTML Escape htmlEscape(String html)

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

Description

html Escape

License

Open Source License

Declaration

public static String htmlEscape(String html) 

Method Source Code

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

public class Main {
    public static String htmlEscape(String html) {
        String htmlEscaped = "";
        for (int i = 0; i < html.length(); i++) {
            char c = html.charAt(i);
            if (c == '\n') {
                htmlEscaped += "<br>";
            } else if (c > 127 || c == '"' || c == '<' || c == '>' || c == '&') {
                htmlEscaped += "&#" + ((int) c) + ';';
            } else {
                htmlEscaped += c;/*from   w w w.j a  va2s .c  o m*/
            }
        }
        return htmlEscaped;
    }
}

Related

  1. escapeHTMLLine(String line)
  2. escapeHTMLSpecialChars(String aText)
  3. escapeHTMLTagCopy(String text)
  4. htmlEscape(final String text)
  5. htmlEscape(Object obj)
  6. htmlescape(String html)
  7. htmlEscape(String input)
  8. htmlEscape(String input)
  9. htmlEscape(String input)