Here you can find the source of listToCsv(List
public static String listToCsv(List<String> strs)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { private static final String COMMA = ","; private static final String QUOTE = "\""; public static String listToCsv(List<String> strs) { return doListToCsv(strs); }/*from w w w . ja va 2s . co m*/ private static <T> String doListToCsv(List<T> list) { if (list == null) { return ""; } StringBuilder csv = new StringBuilder(); boolean first = true; for (T element : list) { if (first) { first = false; } else { csv.append(COMMA); } csv.append(QUOTE).append(element == null ? "" : element).append(QUOTE); } return csv.toString(); } }