Java tutorial
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { /** * Fold up a collection into a string. */ public static String join(Collection a_collection, String a_sDelimiter) /* --------------------------------------------------------------- d1 17-Oct-2006 Adam Bones Created ----------------------------------------------------------------- */ { StringBuffer buffer = new StringBuffer(); Iterator it = a_collection.iterator(); while (it.hasNext()) { buffer.append(it.next()); if (it.hasNext()) { buffer.append(a_sDelimiter); } } return buffer.toString(); } }