Here you can find the source of collectionToString(Collection> collection, String separator)
public static String collectionToString(Collection<?> collection, String separator)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static String collectionToString(Collection<?> collection, String separator) { StringBuilder sb = new StringBuilder(); for (Object o : collection) { sb.append(o.toString());//w ww. ja v a 2s . c om if (separator != null) { sb.append(separator); } } if (sb.length() >= separator.length()) { sb.delete(sb.length() - separator.length(), sb.length()); } return sb.toString(); } }