Android examples for java.lang:String Escape
Escape < > ( ) # & letter
import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.net.URLEncoder; import java.security.SecureRandom; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Locale; public class Main{ public static String getSpclStrCnvrNew(String srcString) { String rtnStr = null;//www.jav a 2 s . c om try { StringBuffer strTxt = new StringBuffer(""); char chrBuff; int len = srcString.length(); for (int i = 0; i < len; i++) { chrBuff = (char) srcString.charAt(i); switch (chrBuff) { case '<': strTxt.append("<"); break; case '>': strTxt.append(">"); break; case '(': strTxt.append("("); break; case ')': strTxt.append(")"); break; case '#': strTxt.append("#"); break; case '&': strTxt.append("&"); break; default: strTxt.append(chrBuff); } } rtnStr = strTxt.toString(); } catch (Exception e) { e.printStackTrace(); } return rtnStr; } }