Here you can find the source of toDelimitedString(List
public static String toDelimitedString(List<String> values, String delimiter, boolean trimValues)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String toDelimitedString(List<String> values, String delimiter, boolean trimValues) { if (values == null || delimiter == null) { return null; }/*from ww w . java2 s . c o m*/ 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; } }