Here you can find the source of mergeArrayIntoString(final Object[] array, String middleDelimiter, String lastDelimiter)
public static String mergeArrayIntoString(final Object[] array, String middleDelimiter, String lastDelimiter)
//package com.java2s; /*/*ww w . jav a 2s. c o m*/ * Copyright 2001-2008 Aqris Software AS. All rights reserved. * * This program is dual-licensed under both the Common Development * and Distribution License ("CDDL") and the GNU General Public * License ("GPL"). You may elect to use one or the other of these * licenses. */ public class Main { public static String mergeArrayIntoString(final Object[] array, String middleDelimiter, String lastDelimiter) { if (array == null) { return null; } if (middleDelimiter == null) { middleDelimiter = ""; } if (lastDelimiter == null) { lastDelimiter = middleDelimiter; } final StringBuffer str = new StringBuffer(); for (int i = 0; i < array.length; i++) { if (i > 0) { if (i == array.length - 1) { str.append(lastDelimiter); } else { str.append(middleDelimiter); } } str.append(array[i].toString()); } return str.toString(); } public static String mergeArrayIntoString(Object[] array, String delimiter) { return mergeArrayIntoString(array, delimiter, delimiter); } public static String toString(final boolean[] array) { String result = "["; for (int i = 0; i < array.length; i++) { if (i > 0) { result += ", "; } result += array[i]; } return result + "]"; } public static String toString(final int[] array) { String result = "["; for (int i = 0; i < array.length; i++) { if (i > 0) { result += ", "; } result += array[i]; } return result + "]"; } }