Here you can find the source of listToString(List
public static String listToString(List<String> list, String split)
//package com.java2s; import java.util.Collection; import java.util.List; public class Main { public static String listToString(List<String> list) { return listToString(list, ","); }//from w w w. j av a2 s.c om public static String listToString(List<String> list, String split) { StringBuilder sb = new StringBuilder(); if (!isEmpty(list)) { for (int i = 0; i < list.size(); i++) { if (i < list.size() - 1) { sb.append(list.get(i) + split); } else { sb.append(list.get(i)); } } } return sb.toString(); } public static <T> boolean isEmpty(Collection<T> c) { if (c == null || c.isEmpty()) { return true; } else { return false; } } }