Here you can find the source of htmlEntities(String html)
public static String htmlEntities(String html)
//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(); } }