Java Collection Element Get getAsString(Collection data, char seperator)

Here you can find the source of getAsString(Collection data, char seperator)

Description

Returns a user specified string representation of a collection

License

LGPL

Parameter

Parameter Description
data -- the collection
seperator -- the separator

Return

the collection represented as string separated by separator.

Declaration

public static String getAsString(Collection<?> data, char seperator) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.Collection;
import java.util.Iterator;

public class Main {
    /**//w  ww  .  ja  v  a 2s  .c  o  m
     * Returns a user specified string representation of a collection 
     * @param data -- the collection
     * @param seperator -- the separator
     * @return the collection represented as string separated by separator.
     */
    public static String getAsString(Collection<?> data, char seperator) {
        Iterator<?> it = data.iterator();
        boolean first = true;
        StringBuffer ret = new StringBuffer();
        while (it.hasNext()) {
            if (first == false) {
                ret.append(seperator);
            } else {
                first = false;
            }
            ret.append(it.next().toString());
        }
        return ret.toString();
    }
}

Related

  1. getArray(Collection dnaCol)
  2. getArrayFromCollection( Collection collection)
  3. GetArrayFromCollection(java.util.Collection col)
  4. getArrays(Object parent, Collection collection)
  5. getAssociationCollectionObjectName(Collection currentObjectColl, Collection prevObjectColl)
  6. getAsString(Collection input)
  7. getAt(Collection col, int index)
  8. getAuthzNameFromEntityName(String entityName, Collection authzProvidersNames)
  9. getByIndex(Collection availableTransitions, int index)

    HOME | Copyright © www.java2s.com 2016