Here you can find the source of collectionToDelimitedString(Collection coll, String delim)
public static String collectionToDelimitedString(Collection coll, String delim)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; public class Main { public static String collectionToDelimitedString(Collection coll, String delim) { return collectionToDelimitedString(coll, delim, "", ""); }/*from w w w .j a v a2 s . c o m*/ public static String collectionToDelimitedString(Collection coll, String delim, String prefix, String suffix) { if (coll == null) { return ""; } StringBuffer sb = new StringBuffer(); Iterator it = coll.iterator(); int i = 0; while (it.hasNext()) { if (i > 0) sb.append(delim); sb.append(prefix).append(it.next()).append(suffix); i++; } return sb.toString(); } }