Java CSV from toCSV(Set list)

Here you can find the source of toCSV(Set list)

Description

to CSV

License

Open Source License

Declaration

public static String toCSV(Set<String> list) 

Method Source Code

//package com.java2s;
/**/*from w w  w.  j  a v a 2 s  . co m*/
 * Vosao CMS. Simple CMS for Google App Engine.
 * 
 * Copyright (C) 2009-2010 Vosao development team.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * email: vosao.dev@gmail.com
 */

import java.util.Collection;

import java.util.List;

import java.util.Set;

public class Main {
    public static String toCSV(Set<String> list) {
        return _toCSV(list);
    }

    public static String toCSV(List<String> list) {
        return _toCSV(list);
    }

    private static String _toCSV(Collection<String> list) {
        StringBuffer result = new StringBuffer();
        int count = 0;
        for (String item : list) {
            result.append((count == 0 ? "" : ",")).append(item);
            count++;
        }
        return result.toString();
    }
}

Related

  1. toCsv(final List list)
  2. toCsv(List list)
  3. toCsv(List list)
  4. toCsv(List strs)
  5. toCSV(List list)
  6. toCSVLine(String[] strArray)
  7. toCSVString(List list, boolean quote)
  8. toCsvString(List values)
  9. toCsvString(List values)