Java Utililty Methods List from Array

List of utility methods to do List from Array

Description

The list of methods to do List from Array are organized into topic(s).

Method

ListasList(Object value)
as List
if (value == null) {
    return Collections.EMPTY_LIST;
} else if (value instanceof List) {
    return (List) value;
} else if (value.getClass().isArray()) {
    return Arrays.asList((Object[]) value);
} else if (value instanceof Enumeration) {
    List answer = new ArrayList();
...
ListasList(Object[] array)
Subtitution for Arrays.asList.
ArrayList list = new ArrayList();
appendArrayToList(array, list);
return list;
ListasList(Object[] array)
as List
@SuppressWarnings("unchecked")
List<T> list = (List<T>) Arrays.asList(array);
return list;
ListasList(Set set)
as List
return (List<V>) Arrays.asList(set.toArray());
ListasList(String data)
Convert an String to List in UTF8
return asList(data.getBytes());
ListasList(String str)
take a string of ints (eg: 1,2,3,4), and return a List of Integers
return asList(str, ",");
ListasList(String string)
as List
if (string == null || "".equals(string))
    return new ArrayList();
String tokens[] = string.split(",");
ArrayList list = new ArrayList();
String arr$[] = tokens;
int len$ = arr$.length;
for (int i$ = 0; i$ < len$; i$++) {
    String t = arr$[i$];
...
ListasList(String strList, String regex)
as List
List<String> list = new ArrayList<String>();
if (null == strList || strList.isEmpty()) {
    return null;
} else {
    String[] strLists = strList.split(regex);
    for (String str : strLists) {
        list.add(str);
return list;
CollectionasList(String val)
as List
return asList(val, "\\s*,\\s*");
ArrayListasList(String valuesSeparatedBy, String delimiter)
as List
ArrayList<String> retVal = new ArrayList<String>();
String[] pieces = valuesSeparatedBy.split(delimiter);
for (String piece : pieces) {
    retVal.add(piece.trim());
return retVal;