Here you can find the source of splitToList(String str, char delimiter)
public static List<String> splitToList(String str, char delimiter)
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static List<String> splitToList(String str, char delimiter) { // return no groups if we have an empty string if (str == null || "".equals(str)) { return Collections.emptyList(); }/*from ww w.ja v a 2 s . c om*/ ArrayList<String> parts = new ArrayList<String>(); int currentIndex; int previousIndex = 0; while ((currentIndex = str.indexOf(delimiter, previousIndex)) > 0) { String part = str.substring(previousIndex, currentIndex).trim(); parts.add(part); previousIndex = currentIndex + 1; } parts.add(str.substring(previousIndex, str.length()).trim()); return parts; } }