List of utility methods to do Collection Join
String | joinSorted(Collection extends Comparable> s, String delimiter) join Sorted List list = new ArrayList(s); Collections.sort(list); return join(list, delimiter); |
String | joinString(Collection join String StringBuilder sb = new StringBuilder(); for (String value : values) { sb.append(value); sb.append(delimiter); if (sb.length() >= delimiter.length()) { sb.setLength(sb.length() - delimiter.length()); return sb.toString(); |
String | joinStringCollection(Collection join String Collection if (collection == null) return null; if (collection.size() == 0) return ""; StringBuilder b = new StringBuilder(); Iterator<String> i = collection.iterator(); while (i.hasNext()) { if (b.length() > 0) ... |
String | joinStrings(Collection strings) Join a collection of strings into a single String object, in the order indicated by the collection's iterator. StringBuffer buf = new StringBuffer(); if (strings == null) { throw new NullPointerException("Received null collection"); for (Iterator it = strings.iterator(); it.hasNext();) { Object obj = it.next(); if (obj == null) { throw new NullPointerException("Received collection containing null object"); ... |
String | joinStrings(Collection join Strings StringBuilder sb = new StringBuilder(1000); for (String name : names) { if (sb.length() > 0) { sb.append(", "); sb.append(name); return sb.toString(); ... |
String | joinStrings(Collection Join a collection of strings into a single String object, in the order indicated by the collection's iterator. StringBuilder buf = new StringBuilder(); if (strings == null) { throw new NullPointerException("Received null collection"); for (String s : strings) { buf.append(s); return buf.toString(); ... |
String | joinStrings(String delim, Collection Joins a collection of strings together sepeated by a delim in the middle StringBuilder sb = new StringBuilder(); boolean first = true; for (String str : strs) { if (first) { first = false; } else { sb.append(delim); sb.append(str); return sb.toString(); |
Collection | joinStringValues(Collection Join the String values while preserving the non-String values. StringBuilder buffer = new StringBuilder(); List<Object> betterValues = new ArrayList<>(); for (Object value : values) { if (value instanceof String) { if (buffer.length() > 0) { buffer.append(" "); buffer.append((String) value); ... |
void | joinTo(Collection> data, String sep, StringBuilder sb) join To if (data == null || data.isEmpty()) return; Iterator<?> iterator = data.iterator(); sb.append(String.valueOf(iterator.next())); while (iterator.hasNext()) { Object obj = iterator.next(); sb.append(sep).append(String.valueOf(obj)); |
String | joinTogether(Collection join Together StringBuffer ret = new StringBuffer(); for (Iterator<String> it = items.iterator(); it.hasNext();) { ret.append(it.next()); if (it.hasNext()) { ret.append(delim); return ret.toString(); ... |