Java HTML Encode toHTMLString(String org)

Here you can find the source of toHTMLString(String org)

Description

to HTML String

License

Open Source License

Declaration

public static String toHTMLString(String org) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toHTMLString(String org) {
        StringBuffer result = new StringBuffer(org.length());
        char[] chars = org.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] == '\"')
                result.append("&quot;");
            else if (chars[i] == '<')
                result.append("&lt;");
            else if (chars[i] == '>')
                result.append("&gt;");
            else if (chars[i] == '&')
                result.append("&amp;");
            else// w  w  w . ja v a2  s  .  c  o  m
                result.append(chars[i]);
        }
        return result.toString();
    }
}

Related

  1. toHTMLEscapedText(String s)
  2. toHtmlInput(String str)
  3. toHtmlLine(String input)
  4. toHTMLString(String in)
  5. toHtmlString(String input)
  6. toHtmlString(String s)
  7. toHTMLString(String str)
  8. toHtmlText(String s)
  9. toHtmlText(String text)