Here you can find the source of arrayToString(String[] array, String separator)
public static String arrayToString(String[] array, String separator)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2010 Intel Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w ww . j av a 2s. c o m*/ * Intel Corporation - Initial API and implementation *******************************************************************************/ public class Main { public static String arrayToString(String[] array, String separator) { return arrayToString((Object[]) array, separator); } public static String arrayToString(Object[] array, String separator) { if (array == null) return null; if (array.length == 0) return ""; //$NON-NLS-1$ if (array.length == 1) return array[0].toString(); StringBuffer buf = new StringBuffer(); buf.append(array[0]); for (int i = 1; i < array.length; i++) { buf.append(separator).append(array[i]); } return buf.toString(); } }