public static String htmlEscape(String input){
  ParamChecks.nullNotPermitted(input,"input");
  StringBuilder result=new StringBuilder();
  int length=input.length();
  for (int i=0; i < length; i++) {
    char c=input.charAt(i);
    if (c == '&') {
      result.append("&amp;");
    }
 else     if (c == '\"') {
      result.append("&quot;");
    }
 else     if (c == '<') {
      result.append("&lt;");
    }
 else     if (c == '>') {
      result.append("&gt;");
    }
 else     if (c == '\'') {
      result.append("&#39;");
    }
 else     if (c == '\\') {
      result.append("&#092;");
    }
 else {
      result.append(c);
    }
  }
  return result.toString();
}

public static String htmlEscape ( String input ) { ParamChecks . nullNotPermitted ( input , "input" ) ; StringBuilder result = new StringBuilder ( ) ; int length = input . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = input . charAt ( i ) ; if ( c == '&' ) { result . append ( "&amp;" ) ; } else if ( c == '\"' ) { result . append ( "&quot;" ) ; } else if ( c == '<' ) { result . append ( "&lt;" ) ; } else if ( c == '>' ) { result . append ( "&gt;" ) ; } else if ( c == '\'' ) { result . append ( "&#39;" ) ; } else if ( c == '\\' ) { result . append ( "&#092;" ) ; } else { result . append ( c ) ; } } return result . toString ( ) ; }
returns a string that is equivalent to the input string , but with special characters converted to html escape sequences .
