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) 2005-2012 Synopsys, Incorporated * 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 a v a2 s . c o m * Synopsys, Inc - Initial implementation *******************************************************************************/ import java.util.Arrays; import java.util.List; public class Main { public static String arrayToString(String array[], String separator) { return listToString(Arrays.asList(array), separator); } public static String arrayToString(String array[]) { return arrayToString(array, " "); } /** * Alternate to List.toString() that formats the list * as a simple string using a specified string as the * separator between elements. * @param l the list of strings to concatenated into a single string. * @param sep the seperator to inserted between each list element. */ public static String listToString(List<String> l, String sep) { if (l == null) return ""; StringBuffer b = new StringBuffer(); appendListToString(b, l, sep); return b.toString(); } /** * Append a list to a string buffer placing a specified * string between each element. * @param b the string buffer to be filled in. * @param l the list of strings to be appended. * @param sep the seperator to inserted between each list element. */ public static void appendListToString(StringBuffer b, List<String> l, String sep) { if (l != null) { for (String element : l) { b.append(sep); b.append(element); } } } }