Java String to List stringToList(String toList, String delimiter)

Here you can find the source of stringToList(String toList, String delimiter)

Description

Convert string to list

License

Apache License

Parameter

Parameter Description
toList string to convert to list
delimiter a parameter

Return

Output List

Declaration

static public ArrayList<String> stringToList(String toList, String delimiter) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**//w ww. j a v  a 2s. c  om
     * Convert string to list
     *
     * @param toList string to convert to list
     * @param delimiter
     * @return Output List
     */
    static public ArrayList<String> stringToList(String toList, String delimiter) {
        ArrayList<String> list = new ArrayList<String>();
        if (toList != null && !toList.isEmpty()) {
            String[] names = toList.split(delimiter);
            for (int i = 0; i < names.length; i++) {
                list.add(names[i]);
            }
        }
        return list;
    }
}

Related

  1. stringToList(String str, char delimiter)
  2. stringToList(String str, String delim)
  3. stringToList(String string, String separator)
  4. stringToList(String text, String seperator)
  5. stringToList(String toList)
  6. stringToList(String value)
  7. stringToListOfTags(String p)
  8. strToAList(String strTokenize)
  9. strToList(String str, String regex)