Java Utililty Methods HTML Decode

List of utility methods to do HTML Decode

Description

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

Method

StringHTMLDecode(String s)
HTML Decode
String mine = s;
for (int i = 0; i < c.length; i++) {
    mine.replaceAll(expansion[i], (c[i] + ""));
return mine;
StringhtmlDecode(String s)
html Decode
if (s == null || s.length() == 0) {
    return s;
s = s.replace("&nbsp;", " ");
s = s.replace("&quot;", "\"");
s = s.replace("&apos;", "'");
s = s.replace("&#39;", "'");
s = s.replace("&lt;", "<");
...
StringhtmlDecode(String strSrc)
html Decode
if (strSrc == null) {
    return "";
strSrc = strSrc.replaceAll("&lt;", "<");
strSrc = strSrc.replaceAll("&gt;", ">");
strSrc = strSrc.replaceAll("&quot;", "\"");
strSrc = strSrc.replaceAll("&#039;", "'");
strSrc = strSrc.replaceAll("&amp;", "&");
...
StringhtmlDecoder(String content)
html Decoder
if (content == null) {
    return "";
content = content.replaceAll("<br>", "");
content = content.replaceAll("\n", "");
content = content.replaceAll("\r", "");
content = content.replaceAll("<", "");
content = content.replaceAll(">", "");
...
StringhtmlEntityDecode(String s)
the following method was taken from suns Decoder and stands under CDDL look here for a converter: http://gmailassistant.sourceforge.net/src/org/freeshell/zs/common/HtmlManipulator.java.html
int i = 0, j = 0, pos = 0;
StringBuffer sb = new StringBuffer();
while ((i = s.indexOf("&", pos)) != -1 && (j = s.indexOf(';', i)) != -1) {
    int n = -1;
    for (i += 1; i < j; ++i) {
        char c = s.charAt(i);
        if ('0' <= c && c <= '9')
            n = (n == -1 ? 0 : n * 10) + c - '0';
...
StringhtmlEntityDecodeSingle(String s)
html Entity Decode Single
int i = 0, j = 0, pos = 0;
StringBuffer sb = new StringBuffer();
while ((i = s.indexOf("&#", pos)) != -1 && (j = s.indexOf(';', i)) != -1) {
    int n = -1;
    for (i += 2; i < j; ++i) {
        char c = s.charAt(i);
        if ('0' <= c && c <= '9')
            n = (n == -1 ? 0 : n * 10) + c - '0';
...
StringtoHtmlString(String src, boolean noSingleQuotes)
to Html String
StringCharacterIterator iter = new StringCharacterIterator(src);
StringBuffer buf = new StringBuffer();
for (char c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
    switch (c) {
    case '\'':
        if (noSingleQuotes) {
            buf.append(c);
        } else {
...