Java Collection to String collectionToString(Collection c)

Here you can find the source of collectionToString(Collection c)

Description

collection To String

License

Open Source License

Declaration

static public String collectionToString(Collection<? extends Object> c) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2007, 2011 Intel Corporation and others.
 * 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://from w w w .  j av  a2s  . c o m
 * Intel Corporation - Initial API and implementation
 *******************************************************************************/

import java.util.Collection;

public class Main {
    static public String collectionToString(Collection<? extends Object> c) {
        return arrayToString(c.toArray());
    }

    static public String arrayToString(Object[] arr) {
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        for (int i = 0; i < arr.length; i++) {
            if (i != 0)
                buf.append(", ");

            buf.append(arr[i].toString());
        }
        buf.append(']');
        return buf.toString();
    }
}

Related

  1. collectionToString(Collection col)
  2. collectionToString(Collection coll)
  3. collectionToString(Collection collection, String delim)
  4. collectionToString(Collection list, String split)
  5. collectionToString(Collection set)
  6. collectionToString(Collection collection, String delimiter)
  7. collectionToString(Collection collection, String seperator)
  8. collectionToString(Collection list, String delimiter)
  9. collectionToString(Collection c)