Java Utililty Methods String to List

List of utility methods to do String to List

Description

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

Method

ListconvertToList(String[] array)
A method to convert a String array to a List of Strings
ArrayList<String> list = new ArrayList<String>();
Collections.addAll(list, array);
return list;
ListstringsToList(final String[] src)
strings To List
if (src == null || src.length == 0) {
    return null;
final List<String> result = new ArrayList<String>();
for (int i = 0; i < src.length; i++) {
    result.add(src[i]);
return result;
...
ListstringToArrayList(String idString)
string To Array List
return Arrays.asList(idString.trim().split("\\s*" + "," + "\\s*"));
voidstringToBooleanList(final String str, final boolean[] listData)
Convert a string into an array of booleans.
if ((str == null) || (str.length() < 1) || (str.indexOf('1') < 0)) {
    java.util.Arrays.fill(listData, false);
    return;
final int len = str.length();
for (int i = 0; i < 6; ++i) {
    if (i < len) {
        listData[i] = (str.charAt(i) == '1');
...
ListstringToIntegerList(String input)
string To Integer List
List<Integer> ret = new ArrayList<Integer>();
String prepared = input.replaceAll(" ", "");
for (String s : prepared.split(",")) {
    ret.add(Integer.valueOf(s));
return ret;
String[]stringToItems(List fontsList, boolean useSeparator)
Convert a list of array of string into a single array of string, ready to be inserted into a combo
List<String> itemsList = new ArrayList<String>();
for (int index = 0; index < fontsList.size(); index++) {
    String[] fonts = fontsList.get(index);
    for (String element : fonts)
        itemsList.add(element);
    if (index + 1 != fontsList.size() && fonts.length > 0 && useSeparator)
        itemsList.add(separator);
String[] result = new String[itemsList.size()];
return itemsList.toArray(result);
ArrayListstringToList(final String string)
Create a list with the given string for execution
return new ArrayList<String>() {
        add(string);
};
ListstringToList(String content)
string To List
if (content == null) {
    return new ArrayList<String>();
content = content.replace("\r", "");
String[] listArray = content.split("\n");
List<String> returnList = new ArrayList<String>();
for (String element : listArray) {
    returnList.add(element);
...
ListstringToList(String content, String splitter)
split the string to tokens by splitter
List<String> list = new ArrayList<String>();
String[] segs = content.split(splitter);
for (String seg : segs) {
    list.add(seg.trim());
return list;
ListstringToList(String delimitedString)
Converts a comma delimited String into a List
List<String> result = new ArrayList<String>();
try {
    for (String s : Arrays.asList(delimitedString.split(","))) {
        result.add(s.trim());
} catch (Exception e) {
    result = new ArrayList<String>();
return result;