Java String Array Merge merge(T[] arr0, String delimiter)

Here you can find the source of merge(T[] arr0, String delimiter)

Description

Merges the given Collection split into a String with the delimiter given.

License

Open Source License

Parameter

Parameter Description
arr0 a parameter
delimiter a parameter

Declaration

public static final <T> String merge(T[] arr0, String delimiter) 

Method Source Code

//package com.java2s;
/**//from w  w  w  . j  a  v  a 2 s  .  com
 * <b>NessusTools</b>: ArrayUtils<br/>
 * <small>Copyright (c)2013 Mike Duncan &lt;<a href="mailto:mike.duncan@waitwha.com">mike.duncan@waitwha.com</a>&gt;</small><p />
 *
 * <pre>
 * This program 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 2
 * of the License, or (at your option) any later version.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * </pre>
 *
 * TODO Document this class/interface.
 *
 * @author Mike Duncan <mike.duncan@waitwha.com>
 * @version $Id$
 * @package com.waitwha.util
 */

public class Main {
    /**
     * Merges the given Collection split into a String with the delimiter given.
     * 
     * @param arr0
     * @param delimiter
     * @return
     */
    public static final <T> String merge(T[] arr0, String delimiter) {
        StringBuffer buffer = new StringBuffer();
        for (T t : arr0)
            buffer.append(t + delimiter);

        return buffer.toString().substring(0, buffer.length() - delimiter.length());
    }
}

Related

  1. merge(String[] arr)
  2. merge(String[] mainSelector, String[] base)
  3. merge(String[] pieces, String sep)
  4. merge(String[] src, String delimiter)
  5. merge(String[] str, String sep)
  6. mergeInts(int[] values, String delimiter)
  7. mergeJoin(String sep, String[] a1, String[] a2)
  8. mergeJoin(String sep, String[] a1, String[] a2)
  9. mergeString(String currentValue, String newValue)