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 delimiter, Collection items)
Create a string by concatenating the elements of a collection using a delimiter between each item
return (items != null) ? join(delimiter, items.toArray(new String[items.size()])) : null;
Stringjoin(String delimiter, Collection stringCollection)
join
StringBuilder sb = new StringBuilder(stringCollection.size() * (16 + delimiter.length()));
for (String str : stringCollection) {
    sb.append(str).append(delimiter);
return sb.toString();
Stringjoin(String delimiter, Collection strings)
Joins a collection of strings into one with the specified delimiter.
if (strings.isEmpty()) {
    return "";
Iterator<String> i = strings.iterator();
StringBuilder sb = new StringBuilder(i.next());
while (i.hasNext()) {
    sb.append(delimiter);
    sb.append(i.next());
...
Stringjoin(String delimiter, Collection values)
Joins a provided collection of String -s via provided delimiter.
if (values == null || values.isEmpty()) {
    return null;
Iterator<String> valuesIterator = values.iterator();
StringBuilder result = new StringBuilder();
result.append(valuesIterator.next());
while (valuesIterator.hasNext()) {
    result.append(delimiter).append(valuesIterator.next());
...
Stringjoin(String glue, Collection c)
join
StringBuilder buf = new StringBuilder();
for (Object o : c) {
    if (buf.length() > 0)
        buf.append(glue);
    buf.append(o.toString());
return buf.toString();
Stringjoin(String glue, Collection pieces)
Join a Collection of Strings together.
return join(glue, pieces.iterator());
Stringjoin(String glue, Collection c)
join
StringBuilder buf = new StringBuilder();
for (Object o : c) {
    if (buf.length() > 0) {
        buf.append(glue);
    buf.append(o.toString());
return buf.toString();
...
Stringjoin(String glue, Collection strings)
join
StringBuilder b = new StringBuilder();
boolean first = true;
for (String s : strings) {
    if (!first) {
        b.append(glue);
    first = false;
    b.append(s);
...
Stringjoin(String glue, Collection items)
Produces a string that consists of the toString of each element in collection with the glue string separating each item
final StringBuilder sb = new StringBuilder();
String join = "";
for (final T item : items) {
    sb.append(join);
    join = glue;
    sb.append(item.toString());
return sb.toString();
...
Stringjoin(String join_string, Collection c)
join
return join(join_string, c.toArray());