Java Utililty Methods Iterable Join

List of utility methods to do Iterable Join

Description

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

Method

Iterablejoin(final Iterable... iterables)
join
return new Iterable<T>() {
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            int index;
            Iterator<? extends T> current;
            T next;
            public boolean hasNext() {
                if (next == null) {
...
Stringjoin(final Iterable items, final String separator)
Pick all elements from the iterable items and convert their string representation into a separator -separated single string.
final StringBuilder sequence = new StringBuilder();
final Iterator<?> iter = items.iterator();
if (iter.hasNext()) {
    final String first = iter.next().toString();
    sequence.append(first);
    while (iter.hasNext()) {
        sequence.append(separator);
        final String next = iter.next().toString();
...
Stringjoin(final Iterable iterable, final String separator)
Copied fom commons StringUtils

Joins the elements of the provided Iterable into a single String containing the provided elements.

if (iterable == null) {
    return null;
return join(iterable.iterator(), separator);
Stringjoin(final Iterable container)
join
return join(container, "");
Stringjoin(final Iterable iterable, final String joinString)
join
return join(iterable.iterator(), joinString);
Stringjoin(final Iterable objs, final String delimiter)
Source: http://snippets.dzone.com/posts/show/91
Iterator<T> iter = objs.iterator();
if (!iter.hasNext())
    return "";
StringBuffer buffer = new StringBuffer(String.valueOf(iter.next()));
while (iter.hasNext())
    buffer.append(delimiter).append(String.valueOf(iter.next()));
return buffer.toString();
Stringjoin(final Iterable objs, final String delimiter)
join
Iterator<T> iter = objs.iterator();
if (!iter.hasNext()) {
    return "";
StringBuffer buffer = new StringBuffer(String.valueOf(iter.next()));
while (iter.hasNext()) {
    buffer.append(delimiter).append(String.valueOf(iter.next()));
return buffer.toString();
Stringjoin(final Iterable source)
join
return join(source, DEFAULT_JOIN_SEPARATOR, DEFAULT_JOIN_NULL_BEHAVIOR);
Iterablejoin(final Iterable... iterables)
join multiple iterables into one
return () -> new Iterator<T>() {
    private int which = 0;
    private Iterator<T> iterator = null;
        while (which < iterables.length) {
            iterator = iterables[which].iterator();
            if (iterator.hasNext())
                break;
...
Stringjoin(final String delimiter, final Iterable objs)
join
if (objs == null)
    return "";
Iterator<T> iter = objs.iterator();
if (!iter.hasNext())
    return "";
String delim = delimiter;
if (delimiter == null)
    delim = "";
...