Here you can find the source of splitList(String data, String delims)
public static final List splitList(String data, String delims)
//package com.java2s; /*//from www . j ava2 s .c o m * The contents of this file are subject to the Mozilla Public License Version 1.1 * (the "License"); you may not use this file except in compliance with the License. * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>. * * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT * WARRANTY OF ANY KIND, either express or implied. See the License for the specific * language governing rights and limitations under the License. * * The Original Code is the Venice Web Communities System. * * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@users.sf.net>, * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * * Contributor(s): */ import java.util.*; public class Main { public static final List splitList(String data, String delims) { if ((data == null) || (delims == null)) return Collections.EMPTY_LIST; ArrayList rc = new ArrayList(); StringBuffer buf = new StringBuffer(); boolean accumulate = false; for (int i = 0; i < data.length(); i++) { // look at each character in turn char ch = data.charAt(i); if (delims.indexOf(ch) >= 0) { // delimiter character - flush the string if we have one if (accumulate) { // flush the buffer rc.add(buf.toString()); buf.setLength(0); accumulate = false; } // end if } // end if else { // ordinary character - accumulate it accumulate = true; buf.append(ch); } // end else } // end for if (accumulate) rc.add(buf.toString()); if (rc.isEmpty()) return Collections.EMPTY_LIST; else return Collections.unmodifiableList(rc); } }