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

Stringjoin(String separator, Iterable elements)
Joins a collection of elements into a single string value, with a specified separator.
StringBuilder sb = new StringBuilder();
for (Iterator<?> i = elements.iterator(); i.hasNext();) {
    sb.append(i.next());
    if (i.hasNext() && separator != null) {
        sb.append(separator);
return sb.toString();
...
Stringjoin(String separator, Iterable objects)
Creates a string with toString() of each object with the given separator.
if (separator == null) {
    throw new NullPointerException("The 'separator' cannot be null");
if (objects == null) {
    throw new NullPointerException("The 'objects' cannot be null");
StringBuilder string = new StringBuilder();
Iterator<?> iterator = objects.iterator();
...
Stringjoin(String separator, Iterable args)
join
StringBuilder builder = new StringBuilder();
for (T project : args) {
    builder.append(project);
    builder.append(separator);
if (builder.length() > 0) {
    return builder.substring(0, builder.length() - 1);
} else {
...
Stringjoin(String seperator, Iterator objects)
join
StringBuilder buf = new StringBuilder();
if (objects.hasNext())
    buf.append(objects.next());
while (objects.hasNext()) {
    buf.append(seperator).append(objects.next());
return buf.toString();
Stringjoin(String seprator, Iterable coll)
join
return join("", seprator, coll);
voidjoin(StringBuilder buf, Iterable values, String separator)
append values to buf separated with the specified separator
for (Iterator<?> i = values.iterator(); i.hasNext();) {
    buf.append(i.next());
    if (i.hasNext()) {
        buf.append(separator);
StringjoinIterableOnComma(Iterable iterable)
join Iterable On Comma
if (iterable != null) {
    StringBuilder buf = new StringBuilder();
    Iterator<?> it = iterable.iterator();
    while (it.hasNext()) {
        buf.append(it.next());
        if (it.hasNext()) {
            buf.append(',');
    return buf.toString();
} else {
    return "";
IterablejoinIterables(final Iterable... iterables)
join Iterables
return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
        Iterator<T>[] iterators = new Iterator[iterables.length];
        for (int i = 0; i < iterators.length; i++) {
            iterators[i] = iterables[i].iterator();
        return joinIterators(iterators);
...
StringjoinStr(CharSequence glue, Iterable parts)
join Str
return joinStr(glue, parts.iterator());
StringjoinStrings(Iterable arr, String glue)
join Strings
StringBuilder ret = new StringBuilder();
boolean first = true;
for (Object s : arr) {
    if (!first) {
        ret.append(glue);
    } else {
        first = false;
    ret.append(s);
return ret.toString();