Android Collection to CSV Convert csv(Collection col)

Here you can find the source of csv(Collection col)

Description

Creates a comma separated value from the collection elements using the toString method

Parameter

Parameter Description
col a parameter

Declaration

public static String csv(Collection<?> col) 

Method Source Code

//package com.java2s;

import java.util.Collection;

public class Main {
    /**/*from  w ww.j  a va 2s  . c  o  m*/
     * Creates a comma separated value from the collection elements
     * using the toString method
     * @param col
     * @return
     */
    public static String csv(Collection<?> col) {
        StringBuilder sb = new StringBuilder();
        int i = 0;
        for (Object c : col) {
            if (i > 0) {
                sb.append(",");
            }
            sb.append(c.toString());
            i++;
        }

        return sb.toString();
    }
}