Here you can find the source of splitCommaSequence(String argumentString)
public static ArrayList<String> splitCommaSequence(String argumentString)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { public static ArrayList<String> splitCommaSequence(String argumentString) { ArrayList<String> arguments = new ArrayList<String>(); int parCount = 0; int lastBeginIndex = 0; for (int i = 1; i < argumentString.length(); i++) { if (argumentString.charAt(i) == '(') parCount++;// w w w .ja va2 s .c o m if (argumentString.charAt(i) == ')') parCount--; if (argumentString.charAt(i) == ',' && parCount == 0) { arguments.add(argumentString.substring(lastBeginIndex, i)); lastBeginIndex = i + 1; } } String toAdd = argumentString.substring(lastBeginIndex, argumentString.length()); if (toAdd.length() != 0 && !toAdd.matches("/^\\s*$/")) { arguments.add(toAdd); } return arguments; } }