List of utility methods to do Collection Join
String | join(String[] collection, String delimiter) Joins the items in collection with a delimiter. return join(Arrays.asList(collection), delimiter);
|
String | join(String[] collection, String separator) Join an array of strings with a separator that appears after every instance in the list -including at the end StringBuilder b = new StringBuilder(); for (String o : collection) { b.append(o); b.append(separator); return b.toString(); |
StringBuilder | join(StringBuilder builder, Collection join int i = 0; for (String s : strs) { if (i != 0) builder.append(','); builder.append(s); i++; return builder; ... |
String | join2(Collection Don't bother to add delimiter for last element StringBuffer buffer = new StringBuffer(); boolean first = true; for (String str : list) { if (!first) { buffer.append(delimiter); buffer.append(str); first = false; ... |
String | joinAndDelimit(final Collection join And Delimit return joinAndDelimit(strings, sep, delim, delim);
|
String | joinAsString(Collection extends Object> collection, String separator) Join each element in a collection using a string separator if (collection.isEmpty()) { return ""; StringBuilder result = new StringBuilder(); boolean first = true; for (Object o : collection) { if (first) { first = false; ... |
String | joinAsStrings(Collection Utility method to join a collection into a string using a supplied separator. if (values == null || values.isEmpty()) { return ""; StringBuilder result = new StringBuilder(); for (T val : values) { result.append(val); result.append(separator); return result.substring(0, result.lastIndexOf(separator)); |
String | joinCol(Collection lst, String delim) split into separate method so we don't get any accidental recursion between join(list) and join(collection). StringBuilder builder = new StringBuilder(); for (Object obj : lst) { if (obj != null) builder.append(obj.toString()); builder.append(delim); builder.delete(builder.length() - delim.length(), builder.length()); return builder.toString(); ... |
String | joinCollection(Collection> collection, char delimiter) Joins the items of a collection together with the argument delimiter followed by a space. return joinCollection(collection, delimiter, true);
|
String | joinCollection(Collection Generates a comma-separated string consisting of quoted string representations of a collection of objects. return joinCollection(a, ",", true); |