Java String to List strToList(String str, String regex)

Here you can find the source of strToList(String str, String regex)

Description

str To List

License

Open Source License

Declaration

public static List<String> strToList(String str, String regex) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> strToList(String str, String regex) {
        List<String> list = new ArrayList<String>();
        if (str.length() == 0 && "".equals(str)) {
            return list;
        } else if (str.length() == 1) {
            list.add(str);//from ww  w .  ja  v  a  2  s . c om
            return list;
        }
        String temp[] = str.split(regex);
        for (String temp_ : temp) {
            list.add(temp_);
        }
        return list;
    }
}

Related

  1. stringToList(String toList)
  2. stringToList(String toList, String delimiter)
  3. stringToList(String value)
  4. stringToListOfTags(String p)
  5. strToAList(String strTokenize)
  6. strToList(String str, String separator)
  7. strToList(String str, String split)
  8. strToList(String value)
  9. toList(String list)