Java CSV String Create getCSV(Collection coll)

Here you can find the source of getCSV(Collection coll)

Description

get CSV

License

Open Source License

Declaration

public static String getCSV(Collection coll) 

Method Source Code

//package com.java2s;
/**/* ww  w.j av a  2 s.  co m*/
 * Copyright 2013,2014 Johnathan E. James - haxwell.org - jj-ccs.com - quizki.com
 *
 * This file is part of Quizki.
 *
 * Quizki is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * Quizki is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Quizki. If not, see http://www.gnu.org/licenses.
 */

import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static String getCSV(Collection coll) {
        StringBuffer sb = new StringBuffer();
        Iterator iterator = coll.iterator();

        while (iterator.hasNext()) {
            sb.append(iterator.next().toString());

            if (iterator.hasNext())
                sb.append(",");
        }

        return sb.toString();
    }
}

Related

  1. csv(String separator, String... elements)
  2. getCSV(Collection values)
  3. getCsv(Collection collection)
  4. getCSVPhrase(Collection objects)
  5. toCSV(int[] a)