List of utility methods to do Iterable Join
String | join(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); ... |
String | join(Iterable extends CharSequence> 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(); ... |
String | join(Iterable extends CharSequence> 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(); |
String | join(Iterable extends Object> iterable, String delimiter) join return join(iterable, delimiter, "", ""); |
String | join(Iterable extends Object> 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; ... |
String | join(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(); |
String | join(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); ... |
String | join(Iterable> elements, String separator) join if (elements == null) { return ""; return join(elements.iterator(), separator); |
String | join(Iterable> elements, String separator) join if (elements == null) { return ""; return join(elements.iterator(), separator); |
String | join(Iterable> items) join return join(items, ""); |