Java CSV String Create getCsv(Collection collection)

Here you can find the source of getCsv(Collection collection)

Description

get Csv

License

Open Source License

Declaration

public static <T> String getCsv(Collection<T> collection) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    public static <T> String getCsv(Collection<T> collection) {
        String result = "";
        if (collection.size() != 0) {
            result = getLocalCsv(collection);
        }//from ww w. ja v  a2  s  .  co  m
        return result;
    }

    public static <T> String getLocalCsv(Collection<T> coll) {
        StringBuilder buff = new StringBuilder();
        int i = 0;
        for (T value : coll) {
            if (i != 0) {
                buff.append(",");
            }
            buff.append(value);
            i++;
        }
        return buff.toString();
    }
}

Related

  1. csv(String separator, String... elements)
  2. getCSV(Collection coll)
  3. getCSV(Collection values)
  4. getCSVPhrase(Collection objects)
  5. toCSV(int[] a)
  6. toCsv(Object[] arr, String format)
  7. toCsv(String value)