Here you can find the source of listToCommaSeparatedList(String prefix, List
public static String listToCommaSeparatedList(String prefix, List<String> stringList)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String listToCommaSeparatedList(String prefix, List<String> stringList) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(prefix);//from w w w. j ava 2 s .c om for (int i = 0; i < stringList.size(); i++) { stringBuilder.append(stringList.get(i)); if ((i + 1) < stringList.size()) stringBuilder.append(","); } return stringBuilder.toString(); } }