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(Collection toJoin, String joinBy)
join
if (toJoin == null) {
    return null;
String joined = "";
for (Object o : toJoin) {
    joined += o.toString() + joinBy;
if (joined.length() > 0) {
...
Stringjoin(Collection tokens, String d)
Join the specified tokens into a delimited string.
if (tokens == null)
    return null;
return join(tokens, d, new StringBuilder()).toString();
Stringjoin(Collection values)
Joins a collection of objects' toString() values into a single string, using the default delimiter of ", " (comma-space).
if (values == null)
    return null;
return join(values.toArray(new Object[values.size()]));
Stringjoin(Collection collection, String separator)
Joins the elements in an input collection using a given separator.
if (collection.isEmpty())
    return "";
Iterator<A> it = collection.iterator();
StringBuilder out = new StringBuilder();
out.append(it.next());
while (it.hasNext())
    out.append(separator).append(it.next());
return out.toString();
...
Stringjoin(Collection data)
join
return join(data, ",");
Stringjoin(Collection c, String separator)
returns a string with elements of the given collection concatenated, separated by given separator
if (c.size() == 0)
    return "";
int n = c.size(), count = 0;
StringBuilder result = new StringBuilder();
for (E e : c) {
    result.append(e);
    count++;
    if (count < n) 
...
Stringjoin(Collection args, String delimeter)
join
StringBuilder sb = new StringBuilder();
Iterator<String> i = args.iterator();
while (i.hasNext()) {
    String s = i.next();
    sb.append(s);
    if (i.hasNext())
        sb.append(delimeter);
return sb.toString();
Stringjoin(Collection c)
join
return join(c, " ");
Stringjoin(Collection c, String joinSymbol)
join
StringBuffer sb = new StringBuffer("");
if (c != null) {
    for (String text : c) {
        sb.append(text).append(joinSymbol);
    int sblen = sb.length();
    int symlen = joinSymbol.length();
    if (sblen > symlen) {
...
Stringjoin(Collection coll, String delimiter)
Returns the comma seprated string example:-a@b.com,c@d.com,d@e.com
if (coll.isEmpty())
    return "";
StringBuilder sb = new StringBuilder();
for (String x : coll)
    sb.append(x + delimiter);
sb.delete(sb.length() - delimiter.length(), sb.length());
return sb.toString();