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(String joiner, Collection strings)
join
if (strings == null)
    return null;
StringBuffer buffer = new StringBuffer();
for (String string : strings) {
    if (buffer.length() > 0) {
        buffer.append(joiner);
    buffer.append(string);
...
Stringjoin(String sep, Collection objects)
join
if (objects == null)
    return "";
StringBuffer res = new StringBuffer();
int i = 0;
for (Iterator iter = objects.iterator(); iter.hasNext();) {
    if (i > 0)
        res.append(sep);
    res.append(iter.next());
...
Stringjoin(String sep, Collection col)
Returns string that contains of all elements of passed collection joined together
StringBuilder sb = new StringBuilder();
for (Object val : col) {
    if (sb.length() > 0)
        sb.append(sep);
    sb.append(castString(val));
return sb.toString();
Stringjoin(String sep, Collection col)
join
StringBuilder sb = new StringBuilder();
for (Object val : col) {
    if (sb.length() > 0)
        sb.append(sep);
    sb.append(val != null ? val.toString() : "null");
return sb.toString();
Stringjoin(String sep, Collection parts)
join
StringBuilder sb = new StringBuilder();
String s = ""; 
for (Object o : parts) {
    sb.append(s);
    if (o != null) {
        sb.append(o);
    s = sep;
...
Stringjoin(String sep, Collection values)
Joins a list of strings (or objects that can be converted to string via Object.toString()) into a single string with fields separated by sep.
if (sep == null)
    throw new IllegalArgumentException();
if (values == null)
    return null;
if (values.isEmpty())
    return "";
StringBuilder s = null;
for (Object a : values) {
...
Stringjoin(String sep, Collection values)
Join collection into a single string, with a separator between.
StringBuilder builder = new StringBuilder();
join(builder, sep, values);
return builder.toString();
Stringjoin(String sep, Collection strings)
join
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String s : strings) {
    if (!first) {
        sb.append(sep);
    } else {
        first = false;
    sb.append(s);
return sb.toString();
Stringjoin(String sep, Collection strs)
Join the string collection into one single string by the separator.
return join(strs, sep);
Stringjoin(String separator, Collection c)
Returns a string formed by the concatenation of string versions of the elements in a collection, separated by a given separator.
StringBuffer buffer = new StringBuffer();
Iterator it = c.iterator();
if (it.hasNext())
    buffer.append(it.next());
while (it.hasNext())
    buffer.append(separator + it.next());
return buffer.toString();