int i,n=0;
String[] words;
String str="dd,gg,kk,ss,tt";
for(i=0;i<str.length();i++){
if(str.charAt(i)==',') n++;
}
System.out.println(n);
words=str.trim().split(",");
for(i=0; i<str.length()-n; i++) {
System.out.print(words[i]+" ");
}
来自http://zhidao.baidu.com/link?url=Xs1GGvLgGx5_AWxy37XkvbELA6G6iANdtu8X3_BAqNsYUgWOLVvoAXZwYs1wjhho7BGTIVo2sMi9g1WMoac7X_