code: public static String replaceAllSpecialChracters(String toBeReplaced) {
  	toBeReplaced = toBeReplaced.replaceAll("&", "&amp;");
  	toBeReplaced = toBeReplaced.replaceAll("<", "&lt;");
  	toBeReplaced = toBeReplaced.replaceAll(">", "&gt;");
  	toBeReplaced = toBeReplaced.replaceAll("\"", "&quot;");
  	toBeReplaced = toBeReplaced.replaceAll("'", "&apos;");
  	// toBeReplaced = toBeReplaced.replace("^", "&circ");
  	// toBeReplaced = toBeReplaced.replaceAll("0xb", "");
  	int len = toBeReplaced.length();
  	char[] temp = toBeReplaced.toCharArray();
  	for (int i = 0; i < len; i++) {
  	    char xCode = temp[i];
  	    if ((xCode > '\u0000' && xCode <= '\u0020') || (xCode == '\u0026')
  		    || (xCode == '\u0022') || (xCode == '\u02C6')
  		    || (xCode == '\u201C') || (xCode == '\u201D')
  		    || (xCode == '\u201E')) {
  		String sub1 = toBeReplaced.substring(0, i);
  		String sub2 = toBeReplaced.substring(i + 1, len);
  
  		String replacement = "";
  		if ((xCode > '\u0000' && xCode <= '\u0020'))
  		    replacement = " ";
  		if (xCode == '\u0026')
  		    replacement = " ";
  		if (xCode == '\u0022')
  		    replacement = " ";
  		if (xCode == '\u02C6')
  		    replacement = " ";
  		if (xCode == '\u201C')
  		    replacement = " ";
  		if (xCode == '\u201D')
  		    replacement = " ";
  		if (xCode == '\u201E')
  		    replacement = " ";
  
  		toBeReplaced = sub1 + replacement + sub2;
  	    }
  	    len = toBeReplaced.length();
  	    temp = toBeReplaced.toCharArray();
  	}
  
  	return (toBeReplaced);
      }
docs: Replaces all special characters in a given string
  
  @param toBeReplaced
  The string to be replaced
  @return the string after the replace