Here you can find the source of joinTogether(Collection
public static String joinTogether(Collection<String> items, String delim)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.Iterator; public class Main { /**//from w ww. ja v a 2 s. co m * @return a delimited string containing the specified items */ public static String joinTogether(Collection<String> items, String delim) { StringBuffer ret = new StringBuffer(); for (Iterator<String> it = items.iterator(); it.hasNext();) { ret.append(it.next()); if (it.hasNext()) { ret.append(delim); } } return ret.toString(); } }