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

Stringjoin(final Collection toJoin)
join
if (toJoin == null) {
    return null;
final String separator = ",";
final StringBuffer buf = new StringBuffer(256);
final Iterator<String> iterator = toJoin.iterator();
while (iterator.hasNext()) {
    buf.append(iterator.next());
...
Stringjoin(final Collection values)
Joins a collection of values with commas, enclosed by brackets.
return join(values, false);
Stringjoin(final Collection values, final char separator)
Joins a collection of header values into a single header value, with a specified specified separator.
if (separator == '"' || separator == '\\') {
    throw new IllegalArgumentException("invalid separator: " + separator);
final StringBuilder sb = new StringBuilder();
if (values != null) {
    for (final String s : values) {
        if (s != null) {
            if (sb.length() > 0) {
...
Stringjoin(final Collection collection)
This static method returns a String representing the the concatenation of the input Collection .
return join(collection, "");
Stringjoin(final Collection collection, final String delimiter)
A method for joing together a collection of strings using a specified delimiter.
if (collection == null || collection.isEmpty()) {
    return "";
Iterator<T> it = collection.iterator();
StringBuffer buffer = new StringBuffer(it.next().toString());
while (it.hasNext()) {
    buffer.append(delimiter).append(it.next().toString());
return buffer.toString();
Stringjoin(final Collection objs, final String delimiter)
join
if (objs == null || objs.isEmpty())
    return "";
Iterator<T> iter = objs.iterator();
StringBuffer buffer = new StringBuffer(iter.next().toString());
while (iter.hasNext())
    buffer.append(delimiter).append(iter.next().toString());
return buffer.toString();
Stringjoin(final Collection objs, String delimiter)
Join elements of any collection with delimiter
if (objs == null || objs.isEmpty())
    return "";
if (!checkVal(delimiter))
    delimiter = "";
Iterator<T> iter = objs.iterator();
StringBuffer buffer = new StringBuffer();
while (iter.hasNext()) {
    Object o = iter.next();
...
Stringjoin(final String d, final Collection c)
Behaves like Perl's join function.
if (d == null) {
    throw new NullPointerException("The delimiter must not be null");
if (c == null) {
    throw new NullPointerException("The collection must not be null");
if (c.isEmpty()) {
    return "";
...
Stringjoin(final String delimiter, final Collection elements)
Same as #join(String,Object) but with a java.util.Collection instead of an Array for the elements.
if (elements == null || elements.isEmpty()) {
    return "";
return join(delimiter, elements.toArray(new Object[elements.size()]));
Stringjoin(final String s, final Collection c)
join
final StringBuilder sb = new StringBuilder();
for (final Object o : c) {
    sb.append(o);
    sb.append(s);
if (c != null && c.size() > 0) {
    sb.delete(sb.length() - s.length(), sb.length());
return sb.toString();