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

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

Description

str To List

License

Open Source License

Declaration

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

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 split) {
        String[] strs = {};/*from  www .java2 s  . c  om*/
        if (str != null && !"".equals(str)) {
            strs = str.split(split);
        }
        List<String> tokenList = new ArrayList<String>();
        for (int i = 0; i < strs.length; i++) {
            String temp = strs[i];
            if (temp != null) {
                temp = strs[i].trim();
                if (!"".equals(temp)) {
                    tokenList.add(temp);
                }
            }
        }
        return tokenList;
    }
}

Related

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