Java Collection to String collectionToCommaDelimitedString(Collection items)

Here you can find the source of collectionToCommaDelimitedString(Collection items)

Description

collection To Comma Delimited String

License

Open Source License

Declaration

public static String collectionToCommaDelimitedString(Collection<?> items) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2015 Pivotal, Inc.//www  . jav  a2  s  .  c  o  m
 * 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:
 *     Pivotal, Inc. - initial API and implementation
 *******************************************************************************/

import java.util.Collection;

public class Main {
    public static String collectionToCommaDelimitedString(Collection<?> items) {
        StringBuilder buf = new StringBuilder();
        boolean first = true;
        for (Object item : items) {
            if (!first) {
                buf.append(",");
            }
            buf.append(item);
            first = false;
        }
        return buf.toString();
    }
}

Related

  1. asStringArray(Collection coll)
  2. asStringArray(Collection collection)
  3. buildString(Collection args, String seperator, int startingArg, int maxLength)
  4. buildString(Collection keys)
  5. buildStringFromListForNuma(Collection list)
  6. collectionToCommaDelimitedString(Collection list)
  7. collectionToCommaSeparatedString(Collection elementCollection)
  8. collectionToCommaSeparatedString(List list)
  9. collectionToCommaString(Collection bundleSelection)