Here you can find the source of joinTextWithCommas(List
public static String joinTextWithCommas(List<String> list)
//package com.java2s; //License from project: Apache License import java.util.Iterator; import java.util.List; public class Main { public static String joinTextWithCommas(List<String> list) { StringBuffer buf = new StringBuffer(); if (list.size() > 0) { Iterator<String> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { String field = iterator.next(); buf.append(field);/*ww w.java2s . c om*/ if (i < list.size()) buf.append(", "); } } return buf.toString(); } }