Java Array to String convertArrayToString(Object[] array, String separator)

Here you can find the source of convertArrayToString(Object[] array, String separator)

Description

Converts an array of objects to a plain string with a given separator

License

Open Source License

Parameter

Parameter Description
array Array of objects
separator Separator

Return

array of objects converted to a plain string with a given separator

Declaration

public static String convertArrayToString(Object[] array, String separator) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010-2013, Embraer S.A., Budapest University of Technology and Economics
 * 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: //w w  w  .j  a  v  a2s.  com
 *     Rodrigo Rizzi Starr, Lincoln Nascimento - initial API and implementation 
 *******************************************************************************/

public class Main {
    /**
     * Converts an array of objects to a plain string with
     * a given separator 
     * @param array Array of objects
     * @param separator Separator
     * @return array of objects converted to a plain string with
     *          a given separator 
     */
    public static String convertArrayToString(Object[] array, String separator) {
        if (array == null) {
            return "";
        }
        StringBuffer result = new StringBuffer();
        for (int i = 0; i < array.length; i++) {
            result.append(array[i]);
            result.append(separator);
        }
        return result.toString();
    }
}

Related

  1. bitsToString(int[] arr)
  2. byteMapToString(Map map)
  3. bytesToString(byte[] buffer)
  4. convertArrayToString(double[] p)
  5. convertArrayToString(Object param)
  6. convertArrayToString(Object[] ig, int count)
  7. convertArrayToString(Object[] objArr)
  8. convertArrayToString(String[] array)
  9. convertArrayToString(String[] array, char seperator)