Java String to List convertToList(String inputString)

Here you can find the source of convertToList(String inputString)

Description

converts a given comma separated String into a list of Strings

License

GNU General Public License

Parameter

Parameter Description
inputString a parameter

Declaration

public static List<String> convertToList(String inputString) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from  w w w  .j  a va2  s  .  com*/
     * converts a given comma separated String into a list of Strings
     * @param inputString
     * @return
     */
    public static List<String> convertToList(String inputString) {
        ArrayList<String> list = new ArrayList<String>();
        if (inputString == null || inputString.equals("")) {
            return list;
        }

        String[] strings = inputString.split(",");
        for (String s : strings) {
            list.add(s);
        }
        return list;
    }
}

Related

  1. convertStringToList(String str)
  2. convertStringToList(String string, String delimiter, boolean trim)
  3. convertStringToList(String value, String delimiter)
  4. convertTextToStringList(String tagText)
  5. convertTextToStringList(String text)
  6. convertToList(String str)
  7. convertToList(String string, String delim)
  8. convertToList(String vars)
  9. convertToList(String[] array)