Here you can find the source of toArray(String str)
public static String[] toArray(String str)
//package com.java2s; //License from project: Open Source License public class Main { public final static String LIST_SEPARATOR = ",|:|;"; public static String[] toArray(String str) { return str.equals("") ? new String[0] : str.split(LIST_SEPARATOR); }//from w ww . j a va 2 s. c o m public static String[] split(String s, String sep, boolean trimWhiteSpace, boolean noEmptyString, int limit) { if (trimWhiteSpace == false && noEmptyString == false) { return s.split(sep, limit); } else if (trimWhiteSpace == false && noEmptyString == true) { String[] sArr = s.split("^(\\Q" + sep + "\\E)+"); if (sArr.length == 1 && sArr[0].length() == 0) return (new String[0]); else { return (sArr[sArr.length - 1].split("(\\Q" + sep + "\\E)+", limit)); } } else if (trimWhiteSpace == true && noEmptyString == false) { return (s.split("\\s*\\Q" + sep + "\\E\\s*", limit)); } else { String[] sArr = s.split("^(\\s*\\Q" + sep + "\\E\\s*)+"); if (sArr.length == 1 && sArr[0].length() == 0) return (new String[0]); else return (sArr[sArr.length - 1].split("(\\s*\\Q" + sep + "\\E\\s*)+", limit)); } } }