Here you can find the source of collectionToDelimitedString(Collection> col, String del)
public static String collectionToDelimitedString(Collection<?> col, String del)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { public static String collectionToDelimitedString(Collection<?> col, String del) { if (col == null || col.isEmpty()) { return ""; }/*w w w .jav a 2 s .c o m*/ StringBuilder sb = new StringBuilder(); Iterator<?> it = col.iterator(); while (it.hasNext()) { sb.append(it.next()); if (it.hasNext()) { sb.append(del); } } return sb.toString(); } }