1. public static String[] splitStringByComma(String source){
if(source==null||source.trim().equals(""))
return null;
StringTokenizer commaToker = new StringTokenizer(source,",");
String[] result = new String[commaToker.countTokens()];
while(commaToker.hasMoreTokens()){
result = commaToker.nextToken();
}
return result;
}
2. 直接用spilt:
String[] result = string.split(str,reg);