Java Collection to String collectionToString(Collection collection, String separator)

Here you can find the source of collectionToString(Collection collection, String separator)

Description

collection To String

License

Open Source License

Declaration

public static String collectionToString(Collection<?> collection, String separator) 

Method Source Code

//package com.java2s;

import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static String collectionToString(Collection<?> collection, String separator) {
        if (collection == null || collection.size() == 0) {
            return "";
        }/*from   w ww  .ja  v  a2 s .c  o m*/

        StringBuffer s = new StringBuffer(32 * collection.size());

        Iterator<?> i = collection.iterator();
        s.append(i.next());

        while (i.hasNext()) {
            s.append(separator).append(i.next());
        }

        return s.toString();
    }
}

Related

  1. collectionToString(Collection c)
  2. collectionToString(Collection c)
  3. collectionToString(Collection c, String separator)
  4. collectionToString(Collection coll, String connectSymbol)
  5. collectionToString(Collection collection, String separator)
  6. collectionToString(Collection elements)
  7. collectionToString(Collection list)
  8. collectionToString(Collection list)
  9. collectionToString(Collection collection, String prefix)