Here you can find the source of listToString(List
public static String listToString(List<String> list, boolean doCommas)
//package com.java2s; import java.util.List; public class Main { public static String listToString(List<String> list, boolean doCommas) { StringBuilder sb = new StringBuilder(); for (String str : list) { if (sb.length() > 0) { if (doCommas) { sb.append(","); }//w ww . j av a 2s. c o m sb.append(" "); } sb.append(str); } return sb.toString(); } }