Java HTML Encode toHtml(String str)

Here you can find the source of toHtml(String str)

Description

to Html

License

Open Source License

Declaration

public static String toHtml(String str) 

Method Source Code

//package com.java2s;

public class Main {

    public static String toHtml(String str) {
        if (str == null)
            return "";
        str = str.replaceAll("&", "&");
        str = str.replaceAll("<", "&lt;");
        str = str.replaceAll(">", "&gt;");
        str = str.replaceAll("\"", "&quot;");
        str = str.replaceAll("\r\n", "\n");
        str = str.replaceAll("\n", "<br/>");
        str = str.replaceAll("\t", " &nbsp;&nbsp;&nbsp;");
        str = str.replaceAll("  ", " &nbsp;");
        return str;
    }/*from  w  w w  .j  a v a2  s  .com*/
}

Related

  1. toHTML(String plainText)
  2. toHTML(String rawText)
  3. toHTML(String s)
  4. toHtml(String s)
  5. toHtml(String str)
  6. toHtml(String str)
  7. toHtml(String str)
  8. toHTML(String string)
  9. toHTML(String text)