Here you can find the source of htmlUnescape(String source)
public static String htmlUnescape(String source)
//package com.java2s; //License from project: Apache License import java.util.Map; import java.util.HashMap; public class Main { private static Map e2i = new HashMap(); /**// w w w . ja va 2 s. c om * Reverses htmlEscape. **/ public static String htmlUnescape(String source) { StringBuffer buf = new StringBuffer(); if (source != null) { for (int i = 0; i < source.length(); ++i) { char ch = source.charAt(i); if (ch == '&') { int semi = source.indexOf(';', i + 1); if (semi == -1) { buf.append(ch); continue; } String entity = source.substring(i + 1, semi); //semi-1); Integer iso = null; if (entity.charAt(0) == '#') iso = new Integer(entity.substring(1)); else iso = (Integer) e2i.get(entity); if (iso == null) { buf.append("&" + entity + ";"); } else { buf.append((char) (iso.intValue())); i = semi; } } else { buf.append(ch); } } } return buf.toString(); } }