List of utility methods to do Iterable Join
String | join(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(); ... |
String | join(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(); ... |
String | join(String separator, Iterable 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 { ... |
String | join(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(); |
String | join(String seprator, Iterable join return join("", seprator, coll); |
void | join(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); |
String | joinIterableOnComma(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 ""; |
Iterable | joinIterables(final Iterable 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); ... |
String | joinStr(CharSequence glue, Iterable extends CharSequence> parts) join Str return joinStr(glue, parts.iterator());
|
String | joinStrings(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(); |