java 按指定字符拆分String并返回List
[1]按指定字符拆分String并返回List
private static ArrayList<String> split(String str) { if (str == null) return null; // Use StringTokenizer because it is faster than split. StringTokenizer tokenizer = new StringTokenizer(str, ","); ArrayList<String> substrings = new ArrayList<String>(); while (tokenizer.hasMoreElements()) { substrings.add(tokenizer.nextToken()); } return substrings; }
版权声明:如无特殊标注,文章均为本站原创,转载时请以链接形式注明文章出处。
评论