Java String to List stringToList(String delimitedString)

Here you can find the source of stringToList(String delimitedString)

Description

Converts a comma delimited String into a List

License

Open Source License

Parameter

Parameter Description
delimitedString a parameter

Return

the List.

Declaration

public static List<String> stringToList(String delimitedString) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;

public class Main {
    /**/* w  w  w . j  a v  a2s .co  m*/
     * Converts a comma delimited String into a List<String>
     * @param delimitedString
     * @return the List. 
     */
    public static List<String> stringToList(String delimitedString) {
        List<String> result = new ArrayList<String>();
        try {
            for (String s : Arrays.asList(delimitedString.split(","))) {
                result.add(s.trim());
            }
        } catch (Exception e) {
            result = new ArrayList<String>();
        }
        return result;
    }
}

Related

  1. stringToIntegerList(String input)
  2. stringToItems(List fontsList, boolean useSeparator)
  3. stringToList(final String string)
  4. stringToList(String content)
  5. stringToList(String content, String splitter)
  6. stringToList(String input)
  7. stringToList(String keywords, String delimiter)
  8. stringToList(String listString, String delimiter)
  9. stringToList(String listText)