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(Collection list, String delimiter)
Joins the list members into a delimiter separated String.
StringBuilder sb = new StringBuilder();
int index = 0;
for (T line : list) {
    sb.append(line);
    if (list.size() != index + 1) {
        sb.append(delimiter);
    index++;
...
Stringjoin(Collection s, String delimiter)
join
StringBuffer buffer = new StringBuffer();
Iterator<T> iter = s.iterator();
while (iter.hasNext()) {
    buffer.append(iter.next());
    if (iter.hasNext()) {
        buffer.append(delimiter);
return buffer.toString();
Stringjoin(Collection things, String delim)
join
return join(things.toArray(), delim);
Stringjoin(Collection values, String join)
join
StringBuilder result = new StringBuilder();
String delim = "";
for (T value : values) {
    result.append(delim);
    result.append(value == null ? "null" : value.toString());
    delim = join;
return result.toString();
...
Stringjoin(final char _separator, final boolean _quotes, final Collection _list, final String _emptyString)
A list of string is joined to one string.
final StringBuilder ret = new StringBuilder();
boolean first = true;
if (_list.isEmpty()) {
    if (_emptyString != null) {
        ret.append(_emptyString);
} else {
    for (final String elem : _list) {
...
Stringjoin(final Collection collection, String delimiter)
join
if (collection == null || collection.size() == 0) {
    return EMPTY;
final StringBuilder sb = new StringBuilder(collection.size() * 16);
for (Object element : collection) {
    sb.append((String) element);
    sb.append(delimiter);
return sb.toString().substring(0, sb.lastIndexOf(delimiter));
Stringjoin(final Collection e, final String s)
Join a collection as a string
if (e == null || e.size() == 0)
    return "";
final StringBuilder builder = new StringBuilder();
for (final Object o : e)
    builder.append(o).append(s);
final String r = builder.toString();
return r.substring(0, r.length() - s.length());
Stringjoin(final Collection items, final String glue)
Implementation of join using a StringBuffer
final StringBuffer buffer = new StringBuffer();
for (final Object o : items) {
    if (buffer.length() > 0) {
        buffer.append(glue);
    buffer.append(o.toString());
return buffer.toString();
...
Stringjoin(final Collection coll, final String delimiter)
Join the Collection elements using the given delimiter.
if (null == coll || coll.size() == 0) {
    return "";
StringBuffer buffer = new StringBuffer();
Iterator<?> iter = coll.iterator();
while (iter.hasNext()) {
    buffer.append(iter.next());
    if (iter.hasNext()) {
...
Stringjoin(final Collection coll, final String glue)
join
return join(coll.toArray(new Object[coll.size()]), glue);