Java String to List stringToList(String value)

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

Description

string To List

License

Open Source License

Declaration

public static List stringToList(String value) throws Exception 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List stringToList(String value) throws Exception {
        if (value == null || value.length() == 0)
            throw new Exception();

        if (value.startsWith("["))
            value = value.substring(1);/*  ww  w  . j  ava 2  s.  c om*/

        if (value.endsWith("]"))
            value = value.substring(0, value.length() - 1);

        String[] elements = value.split(",");
        List<String> list = new ArrayList();
        for (int index = 0; index < elements.length; index++) {
            list.add(elements[index]);
        }
        return list;
    }
}

Related

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