private String replaceEntityRef(String data,String ref,char ch){
  int idx=0;
  StringBuilder buffer=new StringBuilder(data.length());
  while ((idx=data.indexOf(ref)) != -1) {
    buffer.append(data.substring(0,idx));
    buffer.append(ch);
    data=data.substring(idx + ref.length());
  }
  if ((data != null) && (data.length() > 0)) {
    buffer.append(data);
  }
  return buffer.toString();
}

private String replaceEntityRef ( String data , String ref , char ch ) { int idx = 0 ; StringBuilder buffer = new StringBuilder ( data . length ( ) ) ; while ( ( idx = data . indexOf ( ref ) ) != - 1 ) { buffer . append ( data . substring ( 0 , idx ) ) ; buffer . append ( ch ) ; data = data . substring ( idx + ref . length ( ) ) ; } if ( ( data != null ) && ( data . length ( ) > 0 ) ) { buffer . append ( data ) ; } return buffer . toString ( ) ; }
replacing entity ref with original char
