Here you can find the source of splitList(String source, char separator)
public static List<String> splitList(String source, char separator)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static List<String> splitList(String source, char separator) { return splitList(source, separator, false, null); }/*from w w w . ja v a2s . c om*/ public static List<String> splitList(String source, char separator, boolean trim) { return splitList(source, separator, trim, null); } public static List<String> splitList(String source, char separator, boolean trim, List<String> output) { return splitList(source, Character.toString(separator), trim, output); } public static List<String> splitList(String source, String separator) { return splitList(source, separator, false, null); } public static List<String> splitList(String source, String separator, boolean trim) { return splitList(source, separator, trim, null); } public static List<String> splitList(String source, String separator, boolean trim, List<String> output) { if (output == null) output = new ArrayList<String>(); if (source.length() == 0) return output; int pos = 0; do { int npos = source.indexOf(separator, pos); if (npos < 0) npos = source.length(); String piece = source.substring(pos, npos); if (trim) piece = piece.trim(); output.add(piece); pos = npos + 1; } while (pos < source.length()); return output; } }