Here you can find the source of collectionToString(Collection> collection, String separator)
public static String collectionToString(Collection<?> collection, String separator)
//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(); } }