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

StringlistToString(List list)
converts a list to a string taking every element and separating them with a , comma.
StringBuffer result = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
    result.append(", " + list.get(i));
return result.substring(2);
StringlistToString(List list, char sep)
list To String
StringBuffer buffer = new StringBuffer();
if (list != null) {
    for (int i = 0; i < list.size(); i++) {
        if (buffer.length() > 0) {
            buffer.append(sep);
        buffer.append(list.get(i));
return buffer.toString();
StringlistToString(List list, String delim)
Print out a List in a user-friendly string format.
if (list == null) {
    return "NULL";
Iterator i = list.iterator();
return iteratorToString(i, delim, null);
StringlistToString(List list, String glue)
list To String
String result = "";
boolean first = true;
for (Object item : list) {
    if (!first)
        result += glue;
    result += item.toString();
    first = false;
return result;
StringlistToString(List list, String prefix, String suffix, String separator)
list To String
if (list == null)
    return null;
return iteratorToString(list.iterator(), prefix, suffix, separator);
StringlistToString(List list)
list To String
StringBuffer sb = new StringBuffer();
sb.append("[");
boolean first = true;
for (Object o : list) {
    if (first)
        first = false;
    else
        sb.append(", ");
...
StringlistToString(List list)
list To String
if (null == list)
    return "";
if (list.isEmpty())
    return "[]";
StringBuilder sb = new StringBuilder("[");
for (int i = 0; i < list.size(); i++) {
    sb.append(list.get(i));
    if (i != (list.size() - 1)) {
...
StringlistToString(List list, String delim)
Concatenate a list of Strings into a single String.
StringBuilder buf = new StringBuilder();
Iterator<?> it = list.iterator();
while (it.hasNext()) {
    buf.append(String.valueOf(it.next()));
    if (it.hasNext()) {
        buf.append(delim);
return buf.toString();
StringlistToString(List list, String header, String separator, String footer)
list To String
String delim = "";
StringBuilder sb = new StringBuilder(header);
for (int i = 0; i < list.size(); i++) {
    sb.append(delim).append("" + list.get(i));
    delim = separator;
return sb.append(footer).toString();
StringListToString(List lista)
List To String
if (lista != null)
    return lista.toString().replaceAll("\\[", "").replaceAll("\\]", "");
else
    return "";