Java HTML Entity htmlEntities(String html)

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

Description

html Entities

License

Apache License

Declaration

public static String htmlEntities(String html) 

Method Source Code

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

import java.util.HashMap;

import java.util.Map;

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

    public static String htmlEntities(String html) {
        StringBuilder out = new StringBuilder(html.length() * 2);
        for (int p = 0; p < html.length(); p++) {
            Character c = html.charAt(p);
            String entity = entityTable.get(c);
            if (entity != null)
                out.append(entity);//from  www.  ja  v a  2  s.  com
            else
                out.append(c);
        }
        return out.toString();
    }
}

Related

  1. charToHtmlEntity(char entity)
  2. removeHtmlEntity(String content)
  3. replaceHtmlEntitiesWithEmptyString(String stb)
  4. unescapeHTMLEntities(String source)