Java Collection Split getCollectionStringBySplit(Collection collection, String split)

Here you can find the source of getCollectionStringBySplit(Collection collection, String split)

Description

get Collection String By Split

License

Open Source License

Declaration

@SuppressWarnings("rawtypes")
    public static String getCollectionStringBySplit(Collection collection, String split) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    @SuppressWarnings("rawtypes")
    public static String getCollectionStringBySplit(Collection collection, String split) {
        return getArrayStringBySplit(collection.toArray(), split);
    }//from ww  w  .jav  a 2  s .  c om

    public static String getArrayStringBySplit(Object[] collection, String split) {
        StringBuffer buf = new StringBuffer();
        if (split == null || split.length() == 0) {
            split = ",";
        }
        for (Object obj : collection) {
            buf.append(obj).append(split);
        }
        if (buf.toString().endsWith(split))
            return buf.substring(0, buf.length() - 1);
        return buf.toString();
    }
}

Related

  1. fastSplit(final Collection result, final String text, final char separator)
  2. getStringCollection(String str, String split)
  3. getSymbolSplitString(Collection collection, String symbol)
  4. split(Collection d, int n)
  5. split(Collection collections, String separator)