Java Utililty Methods Collection Join

List of utility methods to do Collection Join

Description

The list of methods to do Collection Join are organized into topic(s).

Method

CollectionjoinCollections(final Collection target, final Collection... collections)
Join several all provided collections in the first one provided.
The instance of the target collection is returned to ease use in foreach loops.
if (target == null) {
    throw new IllegalArgumentException("Cannot join collection in null target");
if (collections.length == 0) {
    return target;
for (final Collection<? extends T> collection : collections) {
    target.addAll(collection);
...
StringjoinCollectionToString(Collection list, String str)
join Collection To String
StringBuffer sb = new StringBuffer(100);
for (Object entity : list) {
    if (sb.length() > 0) {
        sb.append(str);
    sb.append(String.valueOf(entity));
return sb.toString();
...
StringjoinCommaDelimitedList(Collection list)
Convert a Collection into a comma delimited String (i.e., CSV).
if (list == null || list.isEmpty()) {
    return EMPTY;
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Object o : list) {
    if (!first) {
        sb.append(", ");
...
StringjoinEmptyItemIncluded(Collection stringCollection, String delimiter)
join Empty Item Included
StringBuffer buffer = new StringBuffer();
if (stringCollection == null || stringCollection.isEmpty()) {
    return "";
Iterator iter = stringCollection.iterator();
while (iter.hasNext()) {
    String item = (String) iter.next();
    if (item == null)
...
StringjoinList(@SuppressWarnings("rawtypes") Collection c)
join List
return joinList(c.toArray());
StringjoinNullSafe(Collection collection, String separator)
join Null Safe
if (null == collection || collection.isEmpty()) {
    return "";
if (null == separator) {
    separator = "";
final StringBuilder sb = new StringBuilder();
for (String str : collection) {
...
StringjoinObjects(Collection objects)
join Objects
return joinObjects(objects, "");
StringjoinQuoted(Collection col)
Joins the given list into a string of quoted values joined with ", ".
if (col.isEmpty())
    return "";
StringBuilder sb = new StringBuilder();
for (String item : col)
    sb.append(",\"").append(item).append('"');
String str = sb.toString();
str = str.replaceFirst(",", "");
return str;
...
StringjoinSequence(Collection sequence)
Joins the list of numbers as a dot-separated string.
if (sequence == null) {
    return null;
StringBuilder builder = new StringBuilder();
int i = 0;
for (long l : sequence) {
    builder.append(l);
    i++;
...
StringjoinSort(Collection c, String separator)
returns a string with elements of the given collection sorted and concatenated, separated by given separator
if (c == null)
    return null;
if (c.size() == 0)
    return "";
int n = c.size(), count = 0;
StringBuilder result = new StringBuilder();
List<E> tmp = new ArrayList<E>(c);
Collections.sort(tmp);
...