Here you can find the source of stringToList(String commas)
Parameter | Description |
---|---|
commas | The string to split. |
public static List<String> stringToList(String commas)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.ListIterator; public class Main { /**// w w w . j ava2s .c o m * Splits a string with commas in it into a string List. * * @param commas The string to split. * @return The split string List. */ public static List<String> stringToList(String commas) { List<String> list = new ArrayList<String>(); ListIterator<String> iterator = Arrays.asList(commas.split("\\s*,\\s*")).listIterator(); if (iterator != null) { while (iterator.hasNext()) { list.add(iterator.next()); } } else list = Arrays.asList(commas); return list; } }