Here you can find the source of toCsvString(List
public static String toCsvString(List<String> values)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String toCsvString(List<String> values) { String csvString = toDelimitedString(values, ",", true); return csvString; }/* w w w .j ava 2s . co m*/ public static String toDelimitedString(List<String> values, String delimiter, boolean trimValues) { if (values == null || delimiter == null) { return null; } StringBuilder stringBuilder = new StringBuilder(); for (int index = 0; index < values.size(); index++) { String value = values.get(index); String valueToUse = value; if (trimValues) { valueToUse = valueToUse.trim(); } if (index > 0) { stringBuilder.append(delimiter); } stringBuilder.append(valueToUse); } String delimitedString = stringBuilder.toString(); return delimitedString; } }