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

StringconvertListToString(List list, String delimiter, char encloser)
Converts list to string concatenating list elements with the delimiter.
return convertListToString(list, delimiter, new Character(encloser));
StringconvertListToString(List list)
Transforms a list to a string which is passed to HSL API
String output = null;
try {
    for (int i = 0; i < list.size(); i++) {
        if (i == 0)
            output = list.get(i).toString();
        else
            output += "|" + list.get(i).toString();
    return output;
} catch (NullPointerException e) {
    return null;
StringconvertListToString(List data)
convert List To String
if (data.size() == 0)
    return "[]";
String result = "[";
for (Object v : data) {
    result += v.toString() + ",";
return result.substring(0, result.length() - 1) + "]";
StringconvertListToString(List list, char delimiter, int estimatedLength)
Converts a list to a string
StringBuilder builder = new StringBuilder(estimatedLength);
for (Object value : list) {
    if (builder.length() > 0) {
        builder.append(delimiter).append(" ");
    builder.append(value);
return builder.toString();
...
StringconvertListToString(List dests)
Converts the List to comma-separated String
StringBuilder destString = new StringBuilder();
for (String dest : dests) {
    destString.append(dest + ",");
destString.deleteCharAt(destString.length() - 1);
return destString.toString();
StringconvertListToString(List itemList, String separator)
convert List To String
if (itemList == null) {
    return null;
StringBuilder result = new StringBuilder();
for (int i = 0; i < itemList.size(); i++) {
    result.append((i > 0) ? separator : ""); 
    result.append(escape(itemList.get(i)));
return result.toString();
StringconvertListToString(List listStr, String separator)
convert List To String
StringBuffer b = new StringBuffer();
int len = listStr.size();
for (int i = 0; i < len; i++) {
    b.append(listStr.get(i));
    if (i != len - 1) {
        b.append(separator);
return b.toString();
StringconvertListToString(List strings)
This method concatenates a list of strings into a single string which are actually stored as list of string into database.
StringBuilder content = new StringBuilder("");
if (strings != null && strings.size() > 0) {
    for (String description : strings) {
        content.append(description);
    return content.toString();
return null;
...
StringconvertListToString(List strList)
convert List To String
String string = ""; 
int i = 0;
if (strList != null) {
    for (String aString : strList) {
        if (i++ > 0)
            string = string.concat(COMMA_SEPARATOR);
        string = string.concat(aString);
return string;
String[]convertListToString(List valueList)
convert List To String
String[] strArr;
if (null != valueList && valueList.size() > 0) {
    strArr = valueList.toArray(new String[1]);
} else {
    strArr = new String[1];
return strArr;