Here you can find the source of htmlcodeToSpecialchars(String str)
public static String htmlcodeToSpecialchars(String str)
//package com.java2s; public class Main { public static String htmlcodeToSpecialchars(String str) { str = str.replaceAll("&", "&"); str = str.replaceAll(""", "\""); str = str.replaceAll("'", "'"); str = str.replaceAll("<", "<"); str = str.replaceAll(">", ">"); 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; } }