Here you can find the source of toSeperatedString(final Collection
public static <T> String toSeperatedString(final Collection<T> list)
//package com.java2s; import java.util.Collection; public class Main { public static <T> String toSeperatedString(final Collection<T> list) { final StringBuffer stringBuffer = new StringBuffer(); for (final T element : list) { if (stringBuffer.length() != 0) stringBuffer.append(","); stringBuffer.append(element.toString()); }/*from w ww. j a va 2 s. c om*/ return stringBuffer.toString(); } public static <T> String toSeperatedString(final Collection<T> list, final String separator) { final StringBuffer stringBuffer = new StringBuffer(); for (final T element : list) { if (stringBuffer.length() != 0) stringBuffer.append(separator); stringBuffer.append(element.toString()); } return stringBuffer.toString(); } }