Here you can find the source of StringToList(String listText, String regex)
public static List<String> StringToList(String listText, String regex)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static List<String> StringToList(String listText, String regex) { if (listText == null || listText.equals("")) { return null; }/*from w w w . ja va 2s . c om*/ List<String> list = new ArrayList<String>(); if (listText.contains(regex)) { String[] text = listText.split(regex); for (String str : text) { list.add(str.replaceAll("\\s*", "")); } } else { list.add(listText.replaceAll("\\s*", "")); } return list; } }