Java Utililty Methods HTML Encode

List of utility methods to do HTML Encode

Description

The list of methods to do HTML Encode are organized into topic(s).

Method

StringhtmlEncode(String s)
Helper method to html encode a string.
StringBuffer sb = new StringBuffer();
int n = s.length();
for (int i = 0; i < n; i++) {
    char c = s.charAt(i);
    switch (c) {
    case '<':
        sb.append("&lt;");
        break;
...
StringhtmlEncode(String s)
html Encode
StringBuffer encodedString = new StringBuffer("");
char[] chars = s.toCharArray();
for (char c : chars) {
    if (c == '<') {
        encodedString.append("&lt;");
    } else if (c == '>') {
        encodedString.append("&gt;");
    } else if (c == '\'') {
...
StringhtmlEncode(String s)
html Encode
return htmlEncode(s, false);
StringHTMLEncode(String s)
HTML Encode
for (int j = 0; j < c.length; j++) {
    s = s.replace(c[j], expansion[j]);
return s;
StringhtmlEncode(String s, boolean encodeSpecialChars)
Escape html entity characters and high characters (eg "curvy" Word quotes).
s = noNull(s, "");
StringBuilder str = new StringBuilder();
for (int j = 0; j < s.length(); j++) {
    char c = s.charAt(j);
    if (c < '\200') {
        switch (c) {
        case '"':
            str.append("&quot;");
...
StringhtmlEncode(String s, boolean encodeWS)
html Encode
if (s == null)
    return null;
char[] ca = s.toCharArray();
StringBuffer res = new StringBuffer(ca.length);
int ls = 0;
boolean blankMet = true;
for (int i = 0; i < ca.length; i++) {
    switch (ca[i]) {
...
StringHtmlEncode(String str)
Html Encode
str = str.replace(">", "&lt;");
str = str.replace(">", "&lt;");
return str;
StringHTMLEncode(String str)
Returns the string encoded for HTML use.
if (null == str)
    return "null";
StringBuffer strbuf = new StringBuffer(str.length());
char tmp;
for (int i = 0; i < str.length(); i++) {
    tmp = str.charAt(i);
    if ('<' == tmp) {
        strbuf.append("&lt;");
...
StringhtmlEncode(String str)
html Encode
if (str == null) {
    return null;
for (int i = 0; i < invalidStr.length; i++)
    str = change(str, invalidStr[i], escapedStr[i]);
return str;
StringhtmlEncode(String str)
html Encode
if (str != null) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < str.length(); i++) {
        char c = str.charAt(i);
        if (c == '<') {
            sb.append("&lt;");
        } else {
            sb.append(c);
...