public static String resolveEntities(String text){
  int ampIndex=text.indexOf('&');
  if (ampIndex == -1) {
    return text;
  }
  StringBuilder sb=new StringBuilder((int)(1.1 * text.length()));
  int prevIndex=0;
  while (ampIndex >= 0) {
    int colonIndex=text.indexOf(';',ampIndex);
    sb.append(text.substring(prevIndex,ampIndex));
    sb.append(resolveEntity(text.substring(ampIndex + 1,colonIndex)));
    prevIndex=colonIndex + 1;
    ampIndex=text.indexOf('&',prevIndex);
  }
  sb.append(text.substring(prevIndex));
  return sb.toString();
}

public static String resolveEntities ( String text ) { int ampIndex = text . indexOf ( '&' ) ; if ( ampIndex == - 1 ) { return text ; } StringBuilder sb = new StringBuilder ( ( int ) ( 1.1 * text . length ( ) ) ) ; int prevIndex = 0 ; while ( ampIndex >= 0 ) { int colonIndex = text . indexOf ( ';' , ampIndex ) ; sb . append ( text . substring ( prevIndex , ampIndex ) ) ; sb . append ( resolveEntity ( text . substring ( ampIndex + 1 , colonIndex ) ) ) ; prevIndex = colonIndex + 1 ; ampIndex = text . indexOf ( '&' , prevIndex ) ; } sb . append ( text . substring ( prevIndex ) ) ; return sb . toString ( ) ; }
replaces all xml character entities with the character they represent .
