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

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

Description

string To List

License

Open Source License

Declaration

public static List<String> stringToList(String listString,
            String delimiter) 

Method Source Code

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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> stringToList(String listString,
            String delimiter) {//from   w  w  w  . j ava2 s  .co  m
        ArrayList<String> result = new ArrayList<String>();
        int last = -1;

        if (listString != null && !listString.isEmpty()) {
            while (listString.indexOf(delimiter, ++last) != -1) {
                result.add(listString.substring(last,
                        listString.indexOf(delimiter, last)));

                last = listString.indexOf(delimiter, last);
            }
            result.add(listString.substring(last, listString.length()));
        }

        return result;
    }
}

Related

  1. stringToList(String content)
  2. stringToList(String content, String splitter)
  3. stringToList(String delimitedString)
  4. stringToList(String input)
  5. stringToList(String keywords, String delimiter)
  6. stringToList(String listText)
  7. StringToList(String listText, String regex)
  8. stringToList(String s)
  9. stringToList(String s)