Java List from Array asList(String val)

Here you can find the source of asList(String val)

Description

as List

License

LGPL

Declaration

public static Collection<String> asList(String val) 

Method Source Code

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

import java.util.Arrays;

import java.util.Collection;
import java.util.Collections;

public class Main {
    public static Collection<String> asList(String val) {
        return asList(val, "\\s*,\\s*");
    }/*from   w  ww.  jav  a2  s. co  m*/

    public static Collection<String> asList(String val, String delim) {
        if (!isEmpty(val)) {
            return Arrays.asList(val.split(delim));
        } else {
            return Collections.emptyList();
        }
    }

    public static boolean isEmpty(String v) {
        return (v == null || v.length() < 1);
    }
}

Related

  1. asList(Set set)
  2. asList(String data)
  3. asList(String str)
  4. asList(String string)
  5. asList(String strList, String regex)
  6. asList(String valuesSeparatedBy, String delimiter)
  7. asList(String... args)
  8. asList(String... strings)
  9. asList(T element)