Java String Escape escapeHTML(String s)

Here you can find the source of escapeHTML(String s)

Description

escape HTML

License

Apache License

Declaration

public static String escapeHTML(String s) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    private static Map<Character, String> HTML_CHAR_ESCAPED_MAP = new HashMap<Character, String>();

    public static String escapeHTML(String s) {
        StringBuilder buffer = new StringBuilder(s.length());
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c != '\r') {
                final String escaped = HTML_CHAR_ESCAPED_MAP.get(c);
                buffer.append(escaped != null ? escaped : c);
            }/*from w  w w. java  2  s  .co  m*/
        }
        return buffer.toString();
    }
}

Related

  1. escape(String str)
  2. escape(String string, String chars)
  3. escapeASN1(String str)
  4. escapeCellText(String text, boolean wrap, boolean multiline)
  5. escapeCharacters(String string)
  6. escapeHTML(String source)
  7. escapeHTMLTags(String in)
  8. escapeInstanceIdentifier(String instanceIdentifier)
  9. escapeJavaString(String str)