Java HTML Encode htmlEncode(String s)

Here you can find the source of htmlEncode(String s)

Description

html Encode

License

Open Source License

Declaration

public static String htmlEncode(String s) 

Method Source Code

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

public class Main {
    public static String htmlEncode(String s) {
        StringBuffer out = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (c > 127 || c == '"' || c == '<' || c == '>') {
                out.append("&#" + (int) c + ";");
            } else {
                out.append(c);//from   ww  w  .  java  2  s.  c o  m
            }
        }
        return out.toString();
    }
}

Related

  1. htmlEncode(Object input)
  2. htmlEncode(String html)
  3. htmlEncode(String html)
  4. htmlEncode(String input)
  5. htmlEncode(String input)
  6. htmlEncode(String s)
  7. htmlEncode(String s)
  8. htmlEncode(String s)
  9. htmlEncode(String s)