标签:
public class StrSplit2{ public static void main(String[] args) { String orgStr="a,b,c,d,e,f"; String [] result = orgStr.split(","); for(int a = 0;a<result.length;a++){ System.out.print(result[a]+"\t"); } } }
import java.util.StringTokenizer; //方案二: public class StrSplit{ public static void main(String[] args) { String orgStr="ab,b,c,d,e,f"; StringTokenizer tokener = new StringTokenizer(orgStr,","); String [] result = new String[tokener .countTokens()]; int i=0; while(tokener. hasMoreTokens ()) { result[i++]=tokener.nextToken(); } for(int a = 0;a<result.length;a++){ System.out.print(result[a]+"\t"); } } }
标签:
原文地址:http://www.cnblogs.com/zhaideyou/p/5928386.html