Java Utililty Methods Collection Join

List of utility methods to do Collection Join

Description

The list of methods to do Collection Join are organized into topic(s).

Method

Stringjoin(String[] collection, String delimiter)
Joins the items in collection with a delimiter.
return join(Arrays.asList(collection), delimiter);
Stringjoin(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();
StringBuilderjoin(StringBuilder builder, Collection strs)
join
int i = 0;
for (String s : strs) {
    if (i != 0)
        builder.append(',');
    builder.append(s);
    i++;
return builder;
...
Stringjoin2(Collection list, String delimiter)
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;
...
StringjoinAndDelimit(final Collection strings, final String sep, final String delim)
join And Delimit
return joinAndDelimit(strings, sep, delim, delim);
StringjoinAsString(Collection 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;
...
StringjoinAsStrings(Collection values, String separator)
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));
StringjoinCol(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();
...
StringjoinCollection(Collection collection, char delimiter)
Joins the items of a collection together with the argument delimiter followed by a space.
return joinCollection(collection, delimiter, true);
StringjoinCollection(Collection a)
Generates a comma-separated string consisting of quoted string representations of a collection of objects.
return joinCollection(a, ",", true);