Here you can find the source of join(Iterator iterator, String separator)
Joins the elements of the provided Iterator
into a single String containing the provided elements.
public static String join(Iterator iterator, String separator)
//package com.java2s; /******************************************************************************* * Copyright Duke Comprehensive Cancer Center and SemanticBits * //from w ww . j a v a 2 s.c om * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/c3pr/LICENSE.txt for details. ******************************************************************************/ import java.util.Iterator; public class Main { /** * <p>Joins the elements of the provided <code>Iterator</code> into * a single String containing the provided elements.</p> **/ public static String join(Iterator iterator, String separator) { if (separator == null) { separator = ""; } StringBuffer buf = new StringBuffer(256); // Java default is 16, probably too small while (iterator.hasNext()) { buf.append(iterator.next()); if (iterator.hasNext()) { buf.append(separator); } } return buf.toString(); } }