Here you can find the source of join(Collection> objects, String token, StringBuilder buf)
public static String join(Collection<?> objects, String token, StringBuilder buf)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Collection; import java.util.Iterator; public class Main { public static String join(Collection<?> objects, String token, StringBuilder buf) { for (Iterator<?> it = objects.iterator(); it.hasNext();) { buf.append(it.next()).append(token); }// www. j a v a 2 s .c o m buf.delete(buf.lastIndexOf(token), buf.length()); // delete last token return buf.toString(); } public static <T> String join(T[] objects, String token, StringBuilder buf) { return join(Arrays.asList(objects), token, buf); } }