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

CharSequencejoin(String delim, Collection values)
join
if (values.isEmpty()) {
    return "";
Iterator<?> iterator = values.iterator();
if (values.size() == 1) {
    return iterator.next().toString();
StringBuilder builder = new StringBuilder();
...
Stringjoin(String delim, Collection collections)
Join.
String[] values = new String[collections.size()];
collections.toArray(values);
return join(delim, 0, collections.size(), values);
Stringjoin(String delim, Collection values)
join
if (values == null || values.size() == 0) {
    return "";
StringBuilder s = new StringBuilder();
for (String v : values) {
    s.append(delim);
    s.append(v);
return s.toString().substring(delim.length());
Stringjoin(String delimeter, Collection items)
join
boolean isFirst = true;
String rval = "";
for (T i : items) {
    if (!isFirst)
        rval += delimeter;
    else
        isFirst = false;
    rval += i.toString();
...
Stringjoin(String delimiter, Collection objects)
join
if (objects == null || objects.isEmpty()) {
    return EMPTY_STRING;
Iterator<? extends Object> iterator = objects.iterator();
StringBuilder builder = new StringBuilder();
builder.append(iterator.next());
while (iterator.hasNext()) {
    builder.append(delimiter).append(iterator.next());
...
Stringjoin(String delimiter, Collection objects)
join
if (objects == null || objects.isEmpty()) {
    return EMPTY_STRING;
Iterator<? extends Object> iterator = objects.iterator();
StringBuilder builder = new StringBuilder();
builder.append(iterator.next());
while (iterator.hasNext()) {
    builder.append(delimiter).append(iterator.next());
...
Stringjoin(String delimiter, Collection a)
join
if (a.isEmpty()) {
    return "";
StringBuilder buffer = new StringBuilder();
for (Object o : a) {
    buffer.append(delimiter);
    buffer.append(o);
return buffer.substring(delimiter.length());
Stringjoin(String delimiter, Collection items)
Joins string items into one string separated by delimiter.
if (isEmpty(items))
    return "";
StringBuilder result = new StringBuilder();
boolean delimOk = !isEmpty(delimiter);
for (Object item : items) {
    if (delimOk && result.length() > 0)
        result.append(delimiter);
    result.append(item);
...
Stringjoin(String delimiter, Collection objects)
join
StringBuilder sb = new StringBuilder();
Iterator<?> iterator = filterNulls(objects).iterator();
while (iterator.hasNext()) {
    Object next = iterator.next();
    sb.append(String.valueOf(next));
    if (iterator.hasNext()) {
        sb.append(delimiter);
return sb.toString();
Stringjoin(String delimiter, Collection parts)
join
return join(delimiter, parts == null ? EMPTY_ARRAY : parts.toArray());