Java Collection Split getSymbolSplitString(Collection collection, String symbol)

Here you can find the source of getSymbolSplitString(Collection collection, String symbol)

Description

Return a string split by the symbol.

License

LGPL

Parameter

Parameter Description
collection a parameter
symbol a parameter

Return

the result is combined by collection and symbol

Declaration

public static String getSymbolSplitString(Collection<?> collection, String symbol) 

Method Source Code

//package com.java2s;
/**/*  w w w .  j a v  a 2s . c o  m*/
 * The Clican-Pluto software suit is Copyright 2009, Clican Company
 * and individual contributors, and is licensed under the GNU LGPL.
 *
 * @author clican
 *
 */

import java.util.Collection;

public class Main {
    /**
     * Return a string split by the symbol.
     * 
     * @param collection
     * @param symbol
     * @return the result is combined by collection and symbol
     */
    public static String getSymbolSplitString(Collection<?> collection, String symbol) {
        return getSymbolSplitString(collection.toArray(), symbol);
    }

    /**
     * 
     * Return a string split by the symbol.
     * 
     * @param array
     * @param symbol
     * @return the result is combined by array and symbol
     */
    public static String getSymbolSplitString(Object[] array, String symbol) {
        if (array == null || array.length == 0) {
            return null;
        }
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < array.length; i++) {
            buffer.append(array[i]);
            if (i != array.length - 1) {
                buffer.append(symbol);
            }
        }
        return buffer.toString();
    }
}

Related

  1. fastSplit(final Collection result, final String text, final char separator)
  2. getCollectionStringBySplit(Collection collection, String split)
  3. getStringCollection(String str, String split)
  4. split(Collection d, int n)
  5. split(Collection collections, String separator)
  6. split(Collection orig, int batchSize)
  7. split(Collection set, int n)