Java Utililty Methods HTML to String

List of utility methods to do HTML to String

Description

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

Method

StringtoText(String html)
to Text
String newline = System.getProperty("line.separator");
return html == null ? ""
        : html.replaceAll("<br/>", newline).replaceAll("<ul>", newline + newline)
                .replaceAll("</ul>", newline).replaceAll("<li>", "* ").replaceAll("</li>", newline);
StringtoText(String html)
Extract the HTML tags from the given input to make the text content more readable.
String newline = System.getProperty("line.separator");
return html == null ? ""
        : html.replaceAll("<br/>", newline).replaceAll("<ul>", newline + newline)
                .replaceAll("</ul>", newline).replaceAll("<li>", "* ").replaceAll("</li>", newline);
StringtoText(String text)
to Text
char[] buf = text.toCharArray();
StringBuilder b = new StringBuilder(text.length());
int idx = 0;
while (idx < buf.length) {
    if (buf[idx] == '<') {
        int endTagPos = 0;
        if (idx + 2 < buf.length && buf[idx + 1] == '!' && buf[idx + 2] == '-') {
            endTagPos = endTagPosition(buf, idx, 3000, false);
...
StringtoTextareaInput(String str)
to Textarea Input
if (str == null)
    return "";
str = str.replaceAll("&", "&amp;");
str = str.replaceAll("<", "&lt;");
str = str.replaceAll(">", "&gt;");
return str;