Java Utililty Methods List to String

List of utility methods to do List to String

Description

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

Method

StringasString(List list)
as String
if (list == null || list.isEmpty())
    return "";
StringBuilder builder = new StringBuilder();
for (Iterator i$ = list.iterator(); i$.hasNext(); builder.append(",")) {
    long a = ((Long) i$.next()).longValue();
    builder.append(a);
if (builder.charAt(builder.length() - 1) == ',')
...
StringasString(List commandLine)
as String
String s = "";
for (String cmd : commandLine)
    s += (s.equals("") ? "" : " ") + cmd;
return s;
ListasStringList(Collection objects)
Returns a list of strings, where the strings are the result of calling String.valueOf( Object ) of each object in the given collection.
List<String> list = new ArrayList<>();
for (Object object : objects) {
    list.add(String.valueOf(object));
return list;
ArrayListasStringList(Collection list)
Calls toString for each element and adds it to a new list.
ArrayList<String> result = new ArrayList<String>(list.size());
for (Object o : list) {
    result.add(o.toString());
return result;
ListasStringList(Collection objects)
Returns a list containing the string representations of the given collection of objects.
List<String> result = new ArrayList<String>();
for (Object o : objects) {
    result.add(String.valueOf(o));
return result;
ListasStringList(List coll)
Returns a string list representation of the given list.
List<String> result = new ArrayList<>();
for (Object t : coll) {
    result.add(t.toString());
return result;
StringBuilderasStringList(Set attributes)
as String List
final StringBuilder b = new StringBuilder();
Iterator<?> iterator = attributes.iterator();
while (iterator.hasNext()) {
    final Object o = iterator.next();
    b.append(o.toString());
    if (iterator.hasNext()) {
        b.append(", ");
return b;
String[]convertListToStrArray(List list)
Converts a List to an String array.
if (list != null) {
    int cnt = list.size();
    String[] strArray = new String[cnt];
    for (int i = 0; i < cnt; i++) {
        String str = (String) list.get(i);
        strArray[i] = new String(str);
    return strArray;
...
StringconvertListToString(Iterable l)
convert List To String
return convertListToString(l, ", ");
StringconvertListToString(List list)
convert List To String
StringBuffer result = new StringBuffer();
String separator = "";
Iterator iter = list.iterator();
while (iter.hasNext()) {
    String line = iter.next().toString();
    result.append(separator);
    result.append(line);
    separator = "\n";
...