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 sequence, String delimiter)
Join string representation of the elements of the given collection separated with the given delimiter.
if (null == sequence) {
    return "null";
if (null == delimiter) {
    delimiter = "";
Iterator<T> iterator = sequence.iterator();
if (!iterator.hasNext()) {
...
Stringjoin(Iterable values, String separator)
join
if (values == null) {
    return "";
Iterator<T> iter = values.iterator();
if (!iter.hasNext()) {
    return "";
StringBuffer toReturn = new StringBuffer(stringVal(iter.next()));
...
Stringjoin(Iterable values, String separator)
join
if (values == null) {
    return "";
Iterator<T> iter = values.iterator();
if (!iter.hasNext()) {
    return "";
StringBuffer toReturn = new StringBuffer(String.valueOf(iter.next()));
...
Stringjoin(Iterator iterator, String separator)
Joins the elements of the provided Iterator into a single String containing the provided elements.

No delimiter is added before or after the list.

final String empty = "";
if (iterator == null) {
    return null;
if (!iterator.hasNext()) {
    return empty;
Object first = iterator.next();
...
Stringjoin(String delimiter, Iterable strings)
Join multiple strings with delimiter.
if (strings == null) {
    return null;
int len = 0;
int count = 0;
for (String s : strings) {
    len += s.length();
    ++count;
...
Stringjoin(String delimiter, Iterable stringsIterable)
join
List<String> strings = new LinkedList<>();
Iterator<String> iterator = stringsIterable.iterator();
while (iterator.hasNext()) {
    strings.add(iterator.next());
StringBuilder ab = new StringBuilder();
for (int i = 0; i < strings.size(); i++) {
    ab.append(strings.get(i));
...
Stringjoin(String delimiter, String wrap, Iterable objs)
join
Iterator<? extends Object> iter = objs.iterator();
if (!iter.hasNext()) {
    return "";
StringBuilder buffer = new StringBuilder();
buffer.append(wrap).append(iter.next()).append(wrap);
while (iter.hasNext()) {
    buffer.append(delimiter).append(wrap).append(iter.next()).append(wrap);
...
Stringjoin(String glue, Iterable pieces)
Join the toString representations of a list of objects, separated by a given string.
StringBuilder result = new StringBuilder();
Iterator<?> it = pieces.iterator();
if (it.hasNext()) {
    result.append(it.next());
while (it.hasNext()) {
    result.append(glue);
    result.append(it.next());
...
Stringjoin(String glue, Iterable tokens)
join
final StringBuilder sb = new StringBuilder();
final Iterator<?> iterator = tokens.iterator();
while (iterator.hasNext()) {
    sb.append(iterator.next());
    if (iterator.hasNext()) {
        sb.append(glue);
return sb.toString();
Stringjoin(String sep, Iterable strings)
join
return join(sep, strings.iterator());