Here you can find the source of joinAndDelimit(final Collection
public static String joinAndDelimit(final Collection<String> strings, final String sep, final String delim)
//package com.java2s; /**//from w w w . j a v a 2 s .co m * ADOBE SYSTEMS INCORPORATED * Copyright 2009-2013 Adobe Systems Incorporated * All Rights Reserved. * * NOTICE: Adobe permits you to use, modify, and distribute * this file in accordance with the terms of the MIT license, * a copy of which can be found in the LICENSE.txt file or at * http://opensource.org/licenses/MIT. */ import java.util.Collection; import java.util.Iterator; public class Main { /** * */ public static String joinAndDelimit(final Collection<String> strings, final String sep, final String delim) { return joinAndDelimit(strings, sep, delim, delim); } /** * */ public static String joinAndDelimit(final Collection<String> strings, final String sep, final String ldelim, final String rdelim) { final String joined = join(strings, sep); return joined.length() > 0 ? ldelim + joined + rdelim : ""; } /** * */ public static String join(final Iterable<String> strings, final String sep) { final StringBuilder b = new StringBuilder(); final Iterator<String> iter = strings.iterator(); if (iter.hasNext()) { b.append(iter.next()); while (iter.hasNext()) b.append(sep).append(iter.next()); } return b.toString(); } }