List of utility methods to do Collection Join
String | join(Collection extends Object> strings, String separator) Joins the elements of the provided Collection collection into a single String string , using the provided separator and string elements. StringBuilder sb = new StringBuilder(); if (strings != null) { Iterator<? extends Object> i = strings.iterator(); while (i.hasNext()) { sb.append(i.next()); if (i.hasNext()) { sb.append(separator); return sb.toString(); |
String | join(Collection extends Object> strs, String separator) join StringBuilder result = null; for (Object o : strs) { if (result == null) { result = new StringBuilder(); } else { result.append(separator); result.append(o); ... |
String | join(Collection> c, String delim) Similar to perl's join() method on lists, but works with all collections. StringBuilder retval = new StringBuilder(); Iterator<?> itr = c.iterator(); if (itr.hasNext()) retval.append(itr.next()); else return ""; while (itr.hasNext()) { retval.append(delim); ... |
String | join(Collection> c, String delimiter) Returns a String formed by the delimited results of calling toString over a collection. StringBuffer sb = new StringBuffer(); boolean needComma = false; for (Object o : c) { if (needComma) { sb.append(delimiter); needComma = true; sb.append(o.toString()); ... |
String | join(Collection> c, String insert) Return the string created by inserting insert between the members of c . return join(c, insert, insert);
|
String | join(Collection> c, String separator) Join operation on a collection if (!isSet(separator)) { throw new IllegalArgumentException("Separator is null or empty"); if (c == null || c.size() == 0) { return ""; StringBuilder sb = new StringBuilder(); for (Object element : c) { ... |
String | join(Collection> col, String delim) join StringBuilder sb = new StringBuilder(); Iterator<?> iter = col.iterator(); if (iter.hasNext()) sb.append(iter.next().toString()); while (iter.hasNext()) { sb.append(delim); sb.append(iter.next().toString()); return sb.toString(); |
String | join(Collection> col, String separator) join StringBuilder sb = new StringBuilder(); Iterator<?> it = col.iterator(); if (!col.isEmpty()) { Object obj = it.next(); sb.append(obj.toString()); while (it.hasNext()) { Object obj = it.next(); ... |
String | join(Collection> coll, String delim) Convenience method to return a Collection as a delimited (e.g. return join(coll, delim, "", ""); |
String | join(Collection> collection, String delimiter) Joins a Collection of typed objects using their toString method, separated by delimiter if (collection == null || collection.isEmpty()) { return EMPTY_STRING; } else if (delimiter == null) { delimiter = EMPTY_STRING; StringBuilder builder = new StringBuilder(); Iterator<?> it = collection.iterator(); while (it.hasNext()) { ... |