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(Iterable elements, String delimiter)
Join the elements in the iterable (by using their toString() method) to a string by using the delimiter
a = {"A", "B", "C"}, delimiter = ";"
result: "A;B;C"
Iterator it = elements.iterator();
if (elements == null || !it.hasNext())
    return "";
StringBuilder sb = new StringBuilder();
for (Object element = it.next(); it.hasNext(); element = it.next()) {
    sb.append(element.toString());
    if (it.hasNext())
        sb.append(delimiter);
...
Stringjoin(Iterable iterable, String delimiter)
join
Iterator<? extends CharSequence> it = iterable.iterator();
if (!it.hasNext())
    return "";
StringBuilder sb = new StringBuilder(it.next());
while (it.hasNext()) {
    sb.append(delimiter).append(it.next());
return sb.toString();
...
Stringjoin(Iterable s, String delimiter)
join
@SuppressWarnings("unchecked")
Iterator<String> iter = (Iterator<String>) s.iterator();
StringBuffer buffer = new StringBuffer(iter.next());
while (iter.hasNext())
    buffer.append(delimiter).append(iter.next());
return buffer.toString();
Stringjoin(Iterable iterable, String delimiter)
join
return join(iterable, delimiter, "", "");
Stringjoin(Iterable joinee, String joiner)
join
String returnMe = "";
Iterator<? extends Object> iterator = joinee.iterator();
while (iterator.hasNext()) {
    returnMe += iterator.next().toString();
    if (iterator.hasNext())
        returnMe += joiner;
return returnMe;
...
Stringjoin(Iterable c, String delimeter)
join
StringBuilder sb = new StringBuilder();
Iterator<?> it = c.iterator();
while (it.hasNext()) {
    sb.append(it.next());
    if (!it.hasNext())
        break;
    sb.append(delimeter);
return sb.toString();
Stringjoin(Iterable elements, String separator)
join
if (elements == null)
    return "";
StringBuilder buf = new StringBuilder();
if (separator == null)
    separator = " ";
for (Object o : elements) {
    if (buf.length() > 0)
        buf.append(separator);
...
Stringjoin(Iterable elements, String separator)
join
if (elements == null) {
    return "";
return join(elements.iterator(), separator);
Stringjoin(Iterable elements, String separator)
join
if (elements == null) {
    return "";
return join(elements.iterator(), separator);
Stringjoin(Iterable items)
join
return join(items, "");