public static String entityEncode(String text){
  String result=text;
  if (result == null) {
    return result;
  }
  return StringEscapeUtils.escapeXml(XMLStringUtil.escapeControlChrs(result));
}

public static String entityEncode ( String text ) { String result = text ; if ( result == null ) { return result ; } return StringEscapeUtils . escapeXml ( XMLStringUtil . escapeControlChrs ( result ) ) ; }
encode entity for html or xml output .
