Here you can find the source of collectionToStr(Collection> collection)
public static String collectionToStr(Collection<?> collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static String collectionToStr(Collection<?> collection) { return collectionToStr(collection, null, null, null, true); }/*from w ww. ja va 2 s. c om*/ public static String collectionToStr(Collection<?> collection, Object separator) { return collectionToStr(collection, separator, null, null, true); } public static String collectionToStr(Collection<?> collection, Object beginBlock, Object endBlock) { return collectionToStr(collection, null, beginBlock, endBlock, true); } public static String collectionToStr(Collection<?> collection, Object separator, Object beginBlock, Object endBlock) { return collectionToStr(collection, separator, beginBlock, endBlock, true); } public static String collectionToStr(Collection<?> collection, Object separator, Object beginBlock, Object endBlock, boolean useConvert) { if (collection == null) return null; if (separator == null) separator = ','; StringBuilder sb = new StringBuilder(); if (beginBlock != null) sb.append(beginBlock); boolean first = true; for (Object ob : collection) { if (!first) sb.append(separator); first = false; if (!useConvert) sb.append(ob); else sb.append(ob); } if (endBlock != null) sb.append(endBlock); return sb.toString(); } }