public static String replaceHtmlEntities(final String s){
  final StringBuilder t=new StringBuilder();
  for (int i=0, n=s.length(); i < n; i++) {
    final char c=s.charAt(i);
    if (c == '&') {
      final int j=s.indexOf(';',i);
      if (j >= 0) {
        final Character unicode=HTML_ENTITY_TO_UNICODE_MAP.get(s.substring(i + 1,j));
        if (unicode != null) {
          t.append((char)unicode);
          i=j;
          continue;
        }
      }
    }
    t.append(c);
  }
  return t.toString();
}

public static String replaceHtmlEntities ( final String s ) { final StringBuilder t = new StringBuilder ( ) ; for ( int i = 0 , n = s . length ( ) ; i < n ; i ++ ) { final char c = s . charAt ( i ) ; if ( c == '&' ) { final int j = s . indexOf ( ';' , i ) ; if ( j >= 0 ) { final Character unicode = HTML_ENTITY_TO_UNICODE_MAP . get ( s . substring ( i + 1 , j ) ) ; if ( unicode != null ) { t . append ( ( char ) unicode ) ; i = j ; continue ; } } } t . append ( c ) ; } return t . toString ( ) ; }
replace html entities in a given string with their unicode character representations .
