Here you can find the source of commaDelimitedListToStringArray(String str)
public static String[] commaDelimitedListToStringArray(String str)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static String[] commaDelimitedListToStringArray(String str) { return delimitedListToStringArray(str, ","); }/* w w w . j a va 2s. com*/ public static String[] delimitedListToStringArray(String str, String delimiter) { if (str == null) return new String[0]; if (delimiter == null) { return new String[] { str }; } List result = new ArrayList(); if ("".equals(delimiter)) { for (int i = 0; i < str.length(); i++) result.add(str.substring(i, i + 1)); } else { int pos = 0; int delPos = 0; while ((delPos = str.indexOf(delimiter, pos)) != -1) { result.add(str.substring(pos, delPos)); pos = delPos + delimiter.length(); } if ((str.length() > 0) && (pos <= str.length())) { result.add(str.substring(pos)); } } return toStringArray(result); } public static String[] toStringArray(Collection collection) { if (collection == null) return null; return (String[]) collection.toArray(new String[collection.size()]); } }