Java HTML htmlcodeToSpecialchars(String str)

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

Description

htmlcode To Specialchars

License

Open Source License

Declaration

public static String htmlcodeToSpecialchars(String str) 

Method Source Code

//package com.java2s;

public class Main {

    public static String htmlcodeToSpecialchars(String str) {
        str = str.replaceAll("&", "&");
        str = str.replaceAll(""", "\"");
        str = str.replaceAll("'", "'");
        str = str.replaceAll("&lt;", "<");
        str = str.replaceAll("&gt;", ">");
        return str;
    }//from   w  ww . j a  v a  2  s.c  o m

    public static String replaceAll(String s, String sf, String sb) {
        int i = 0;
        int j = 0;
        int l = sf.length();
        boolean b = true;
        boolean o = true;
        String str = "";
        do {
            j = i;
            i = s.indexOf(sf, j);
            if (i > j) {
                str = str + s.substring(j, i);
                str = str + sb;
                i += l;
                o = false;
            } else {
                str = str + s.substring(j);
                b = false;
            }
        } while (b);
        if (o)
            str = s;

        return str;
    }
}

Related

  1. htmlBold(String content)
  2. htmlButton(String value, String action, int width)
  3. HTMLcheck(String doc)
  4. htmlCode(char tok)
  5. htmlcodeToSpecialchars(String str)
  6. htmlContentHeaderGen(String providerNo, String output, String errorMsg)
  7. htmlConvert(String htmlStr)
  8. HTMLEnc(String s)
  9. htmlEnclose(String html)