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

StringconvertListToStringWithSeparator(List myList, String separator)
convert List To String With Separator
StringBuilder result = new StringBuilder();
Iterator<String> iter = myList.iterator();
while (iter.hasNext()) {
    String item = iter.next();
    result.append(item);
    if (iter.hasNext()) {
        result.append(separator);
return result.toString();
StringlistToStr(Collection a, char sep)
list To Str
return listToStr(a, String.valueOf(sep));
StringlistToStr(Collection c, String delim)
list To Str
StringBuilder sb = new StringBuilder();
int a = 0;
for (Iterator<TypeName> i = c.iterator(); i.hasNext();) {
    TypeName s = i.next();
    sb.append(s);
    if (++a >= c.size())
        break;
    sb.append(delim);
...
StringlistToStr(List lst)
Return a string containing the comma-delimited string representation of the input list.
StringBuilder sb = new StringBuilder();
formatList(sb, lst);
return sb.toString();
StringlistToStr(List list)
list To Str
StringBuilder sb = new StringBuilder();
for (String s : list) {
    sb.append(s);
    sb.append("\n");
return sb.toString();
StringlistToStr(List stringList)
list To Str
StringBuffer result = new StringBuffer();
int size = stringList.size();
for (int i = 0; i < size; i++) {
    String s = stringList.get(i);
    result.append(s);
    if (i < size - 1) {
        result.append(",");
return result.toString();
String[]listToStrArray(List list)
list To Str Array
if (list != null) {
    String curStr[] = new String[list.size()];
    int n = 0;
    for (Iterator j = list.iterator(); j.hasNext(); n++) {
        curStr[n] = (String) j.next();
    return curStr;
return null;
StringlistToString(final List l)
list To String
return Arrays.toString(l.toArray());
StringlistToString(Collection col)
Returns a space seperated string from a string collection.
Iterator<String> items = col.iterator();
StringBuilder sb = new StringBuilder();
while (items.hasNext()) {
    sb.append(items.next().trim()).append(" ");
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
StringlistToString(Collection l)
list To String
StringBuffer result = new StringBuffer();
if (l != null) {
    Iterator<String> iter = l.iterator();
    while (iter.hasNext()) {
        String s = (String) iter.next();
        result.append(s);
        if (iter.hasNext()) {
            result.append(",");
...