Here you can find the source of getFlatString(Collection extends Object> elements)
public static String getFlatString(Collection<? extends Object> elements)
//package com.java2s; //License from project: LGPL import java.util.Collection; public class Main { public static String getFlatString(Collection<? extends Object> elements) { return getFlatString(",", false, elements.toArray()); }//from w ww . j a v a2s. c o m public static String getFlatString(String seperator, boolean skipNulls, Object... elements) { StringBuilder builder = new StringBuilder(); boolean firstWritten = false; for (int index = 0; index < elements.length; index++) { if (!skipNulls || elements[index] != null) { if (firstWritten) { builder.append(seperator); } else { firstWritten = true; } builder.append(elements[index]); } } return builder.toString(); } }