Here you can find the source of join(Iterator iterator, String s)
public static String join(Iterator iterator, String s)
//package com.java2s; //License from project: Apache License import java.util.Arrays; import java.util.Iterator; public class Main { public static String join(Object aobj[], String s) { return join(Arrays.asList(aobj).iterator(), s); }// w w w . j a va 2 s. co m public static String join(Iterator iterator, String s) { StringBuffer stringbuffer = new StringBuffer(); do { if (!iterator.hasNext()) break; stringbuffer.append(iterator.next()); if (iterator.hasNext()) stringbuffer.append(s); } while (true); return stringbuffer.toString(); } }