转换&#为原来的字符

	private static String unknow2chines(String str){
		String result = "";
		int start = 0, end = 0;
		while(start < str.length())
		{
			start = str.indexOf("&#", end);
			if(start >= 0){
				result += str.substring(end, start);
				start = start + 2;
				end = str.indexOf(";", start);
				if(end >= 0)
				{
					String temp = str.substring(start, end);
					int a = Integer.valueOf(temp);					
					char[] ch = new char[]{(char) a};					
					result += new String(ch);
					start = ++end;
				}else{
					return result + "&#" + str.substring(start);
				}
			}else{
				return result + str.substring(end);
			}
		}
		return result.trim();
	}
posted @ 2012-03-30 10:30  GG大婶  阅读(400)  评论(0编辑  收藏  举报