Here you can find the source of listToString(List list, String prefix, String suffix, String separator)
public static String listToString(List list, String prefix, String suffix, String separator)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static String listToString(List list, String prefix, String suffix, String separator) { if (list == null) return null; return iteratorToString(list.iterator(), prefix, suffix, separator); }//w w w .ja v a 2 s. c o m public static String iteratorToString(Iterator i, String prefix, String suffix, String separator) { StringBuffer sb = new StringBuffer(); boolean first = true; for (; i.hasNext();) { if (first) { first = false; } else sb.append(separator); sb.append(prefix); sb.append(i.next().toString()); sb.append(suffix); } return sb.toString(); } }