Here you can find the source of join(Object[] array, String delimiter)
public static String join(Object[] array, String delimiter)
//package com.java2s; /*//from w w w . ja v a 2s . c o m * This file is part of the Raster Storage Archive (RSA). * * The RSA is free software: you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software * Foundation, either version 3 of the License, or (at your option) any later * version. * * The RSA is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along with * the RSA. If not, see <http://www.gnu.org/licenses/>. * * Copyright 2013 CRCSI - Cooperative Research Centre for Spatial Information * http://www.crcsi.com.au/ */ import java.util.Arrays; import java.util.Collection; import java.util.Iterator; public class Main { public static String join(Object[] array, String delimiter) { return join(Arrays.asList(array), delimiter); } public static String join(Collection<?> array, String delimiter) { if (array.size() == 0) return ""; Iterator<?> iter = array.iterator(); StringBuilder sb = new StringBuilder(); sb.append(iter.next().toString()); while (iter.hasNext()) { sb.append(delimiter); sb.append(iter.next().toString()); } return sb.toString(); } }