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 iterable, String separator)
join
if (iterable == null)
    return null;
Iterator<E> iterator = iterable.iterator();
StringBuffer buf = new StringBuffer(256);
while (iterator.hasNext()) {
    E elem = iterator.next();
    if (elem != null)
        buf.append(elem);
...
Stringjoin(Iterable array)
join
return join(array, ",");
Stringjoin(Iterable items, String separator)
join
final StringBuilder builder = new StringBuilder();
final Iterator<String> it = items.iterator();
while (it.hasNext()) {
    builder.append(it.next());
    if (it.hasNext()) {
        builder.append(separator);
return builder.toString();
Stringjoin(Iterable iterable, String delimiter)
Joins content of any Iterable object into string with specified delimiter.
if (iterable == null)
    return "";
Iterator<String> i = iterable.iterator();
StringBuilder builder = new StringBuilder();
if (i.hasNext())
    builder.append(i.next());
while (i.hasNext()) {
    builder.append(delimiter).append(i.next());
...
Stringjoin(Iterable s, String delimiter)
Just strings with a delimiter.
if (s == null)
    return "";
Iterator<String> iter = s.iterator();
StringBuilder builder = new StringBuilder(iter.next());
while (iter.hasNext()) {
    builder.append(delimiter).append(iter.next());
return builder.toString();
...
Stringjoin(Iterable s, String delimiter)
Joins array of strings to string
if (s == null)
    return "";
Iterator<String> iter = s.iterator();
StringBuilder builder = new StringBuilder(iter.next());
while (iter.hasNext()) {
    builder.append(delimiter).append(iter.next());
return builder.toString();
...
Stringjoin(Iterable s, String delimiter)
join
StringBuilder buffer = new StringBuilder(64);
Iterator iter = s.iterator();
if (iter.hasNext()) {
    buffer.append(nvl(iter.next(), ""));
    while (iter.hasNext()) {
        buffer.append(delimiter);
        buffer.append(nvl(iter.next(), ""));
return buffer.toString();
Stringjoin(Iterable source, char delimiter)
join
final StringBuilder sb = new StringBuilder();
final Iterator<String> i = source.iterator();
while (i.hasNext()) {
    String token = i.next();
    if (token != null) {
        sb.append(token);
    if (i.hasNext()) {
...
Stringjoin(Iterable source, String separator)
Join an Iterable of String into one string with a separator
Iterator<String> iterator = null;
if (source == null) {
    return "";
iterator = source.iterator();
if (!(iterator.hasNext())) {
    return "";
StringBuilder builder = new StringBuilder(iterator.next());
while (iterator.hasNext()) {
    builder.append(separator).append(iterator.next());
return builder.toString();
Stringjoin(Iterable strings)
Concatenates strings, using whitespaces as separator.
return join(" ", strings);