java 分隔符 字符串转换字符串数组

//字符串转换字符串数组	
public static String[] split(String source){
        if(source == null || source.trim().equals("")) return null;
        //‘,’作为分隔符
        StringTokenizer commaToker = new StringTokenizer(source, ", ");
        String[] result = new String[commaToker.countTokens()];
        int m=0;
        while(commaToker.hasMoreTokens()){
            result[m] = commaToker.nextToken();
            m++;
        }
        return result;
    }
String[] arr = str.split(",");

 

你可能感兴趣的:(java,字符串转字符串数组)