常用工具代碼總結

1.xml 字符串處理
	public static String htmlEncode(int i){
	     if (i=='&') return "&";
	     else if (i=='<') return "<";
	     else if (i=='>') return ">";
	     else if (i=='"') return """;
	     else if (i == ' ') return " ";
	     else if (i == '	') return "  ";
	     else return ""+(char)i;
	}
	/**
	 * 處理xml文件特殊字符
	 * @param st
	 * @return
	 */
	public static String htmlEncode(String st){
	     StringBuilder buf = new StringBuilder();
	     for (int i = 0;i<st.length();i++){
	         buf.append(htmlEncode(st.charAt(i)));
	     }
	     return buf.toString();
	}

不斷補充中....


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章