List of utility methods to do Iterable Join
String | join(CharSequence delimiter, Iterable tokens) Returns a string containing the tokens joined by delimiters. StringBuilder sb = new StringBuilder(); Iterator<?> it = tokens.iterator(); if (it.hasNext()) { sb.append(it.next()); while (it.hasNext()) { sb.append(delimiter); sb.append(it.next()); return sb.toString(); |
String | join(CharSequence delimiter, Iterable tokens) join StringBuilder sb = new StringBuilder(); boolean firstTime = true; for (Object token : tokens) { if (firstTime) { firstTime = false; } else { sb.append(delimiter); sb.append(token); return sb.toString(); |
String | join(CharSequence delimiter, Iterable extends CharSequence> elements) join if (delimiter == null) { delimiter = ""; StringBuilder buffer = new StringBuilder(); Iterator<? extends CharSequence> it = elements.iterator(); while (it.hasNext()) { buffer.append(it.next()); if (it.hasNext()) { ... |
String | join(CharSequence separator, Iterable> strings) Concatenates strings, using a separator. Iterator<?> i = strings.iterator(); if (!i.hasNext()) { return ""; StringBuilder sb = new StringBuilder(i.next().toString()); while (i.hasNext()) { sb.append(separator); sb.append(i.next().toString()); ... |
String | join(final CharSequence sep, final Iterable> src) join return join(sep, new StringBuffer(), src).toString(); |
String | join(final Iterable extends CharSequence> elements, final String separator) join final StringBuilder buf = new StringBuilder(); for (final CharSequence element : elements) { buf.append(element).append(separator); if (buf.length() > 0) { buf.setLength(buf.length() - separator.length()); return new String(buf); ... |
String | join(final Iterable extends Object> iterable, final CharSequence separator) Joins the string representations of an Iterable collection of objects to one continues string while separating the entities with the provided separator. Iterator<? extends Object> oIt; if (iterable == null || (!(oIt = iterable.iterator()).hasNext())) { return ""; final StringBuilder sb = new StringBuilder(String.valueOf(oIt.next())); while (oIt.hasNext()) { sb.append(separator).append(oIt.next()); return sb.toString(); |
String | join(final Iterable extends Object> objects, final CharSequence separator) Joins the given collection of Objects using the given separator and each Object's normal toString() method. StringBuilder result = new StringBuilder(); for (Iterator<? extends Object> iter = objects.iterator(); iter.hasNext();) { result.append(iter.next().toString()); if (iter.hasNext()) { result.append(separator); return result.toString(); ... |
String | join(final Iterable extends Object> tokens, final String delimiter) join Iterator<? extends Object> oIter; if (tokens == null || (!(oIter = tokens.iterator()).hasNext())) return ""; StringBuilder oBuilder = new StringBuilder(String.valueOf(oIter.next())); while (oIter.hasNext()) { oBuilder.append(delimiter).append(oIter.next()); return oBuilder.toString(); ... |
String | join(final Iterable extends String> iterable, final String separator) join return join(iterable, separator, separator);
|