Java Collection to String collectionToString(final Collection aCol, final String aSepLines)

Here you can find the source of collectionToString(final Collection aCol, final String aSepLines)

Description

collection To String

License

Open Source License

Parameter

Parameter Description
aCol a parameter
aSepLines a parameter

Declaration

public static String collectionToString(final Collection<?> aCol,
        final String aSepLines) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 www.isandlatech.com (www.isandlatech.com)
 * 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.ja v  a2s .  c  o m
 *    ogattaz (isandlaTech) - initial API and implementation
 *******************************************************************************/

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

public class Main {
    /**
     * @param aCol
     * @param aSepLines
     * @return
     */
    public static String collectionToString(final Collection<?> aCol,
            final String aSepLines) {

        StringBuilder wRes = new StringBuilder(2048);
        Iterator<?> wIt = aCol.iterator();
        while (wIt.hasNext()) {
            if (wRes.length() != 0) {
                wRes.append(aSepLines);
            }
            Object wObj = wIt.next();
            if (wObj == null) {
                wRes.append("null");
            } else {
                wRes.append(wObj.toString());
            }
        }
        return wRes.toString();
    }
}

Related

  1. collectionToString(Collection collection)
  2. collectionToString(Collection col, String sep)
  3. collectionToString(Collection collection)
  4. collectionToString(Collection list)
  5. collectionToString(final Collection collection, final String recordSeparator)
  6. collectionToString(final Collection c)
  7. collectionToString(final Collection collection, final String separator)
  8. collectionToString(final Collection elements, final String separator)
  9. collectionToString(final String separator, final Collection coll)