Here you can find the source of concatStrings(Collection
Parameter | Description |
---|---|
strings | a parameter |
public static String concatStrings(Collection<String> strings)
//package com.java2s; //License from project: LGPL import java.util.Collection; public class Main { /**/*w w w . ja v a2 s . c o m*/ * Concatenate all String elements using a "," delimiter * * @param strings * @return single string, with comma separated elements */ public static String concatStrings(String[] strings) { StringBuffer buffer = new StringBuffer(); for (String string : strings) { if (buffer.length() > 0) { buffer.append(","); } buffer.append(string); } return buffer.toString(); } /** * Takes Collection of Strings and returns them as a single line of comma separated strings. * See {@link #concatStrings(String[])} * @param strings * @return */ public static String concatStrings(Collection<String> strings) { return concatStrings(strings.toArray(new String[strings.size()])); } }