Java List to String listToString(Collection l)

Here you can find the source of listToString(Collection l)

Description

list To String

License

Open Source License

Declaration

public static String listToString(Collection<String> l) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static String listToString(Collection<String> l) {
        StringBuffer result = new StringBuffer();
        if (l != null) {
            Iterator<String> iter = l.iterator();
            while (iter.hasNext()) {
                String s = (String) iter.next();
                result.append(s);//from ww w .jav  a 2  s.  c o m
                if (iter.hasNext()) {
                    result.append(",");
                }
            }
        }
        return result.toString().trim();
    }
}

Related

  1. listToStr(List list)
  2. listToStr(List stringList)
  3. listToStrArray(List list)
  4. listToString (final List l)
  5. listToString(Collection col)
  6. listToString(final List list, final String separator)
  7. listToString(final List list)
  8. listToString(final List stringList)
  9. listToString(Iterable list)