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 items, final String inBetween)
Construct a string by toString()ing each item in the collection with inBetween between each item.
final StringBuilder builder = new StringBuilder();
for (final Object item : items) {
    if (builder.length() > 0)
        builder.append(inBetween);
    builder.append(item);
return builder.toString();
Stringjoin(final Collection list, final String inbetween)
join
final StringBuilder builder = new StringBuilder();
for (final Object object : list) {
    if (builder.length() > 0) {
        builder.append(inbetween);
    builder.append(object.toString());
return builder.toString();
...
Stringjoin(final Collection strings, String delimeter)
Convenience function for joining strings using a delimeter
if (delimeter == null) {
    delimeter = ",";
if (strings.isEmpty()) {
    return "";
StringBuffer joined = new StringBuffer();
Iterator<?> stringIter = strings.iterator();
...
Stringjoin(final Collection values, final String separator)
join
if (values == null)
    return "";
StringBuilder sb = new StringBuilder();
Iterator<Object> it = values.iterator();
while (it.hasNext()) {
    sb.append(String.valueOf(it.next()));
    if (it.hasNext())
        sb.append(separator);
...
Stringjoin(final Collection aStrings, final String aSeparator)
Join the given strings into a single string separated by the given separator.
final StringBuilder sb = new StringBuilder();
Iterator<String> i = aStrings.iterator();
while (i.hasNext()) {
    sb.append(i.next());
    if (i.hasNext()) {
        sb.append(aSeparator);
return sb.toString();
Stringjoin(final Collection chunks, final String delimiter)
Join a collection of strings together into one.
StringBuilder sb = new StringBuilder();
if (!chunks.isEmpty()) {
    Iterator<String> itr = chunks.iterator();
    sb.append(itr.next());
    while (itr.hasNext()) {
        sb.append(delimiter);
        sb.append(itr.next());
return sb.toString();
Stringjoin(final Collection collection, final String separator)
join
if (collection == null || collection.isEmpty()) {
    return null;
final StringBuilder buffer = new StringBuilder();
for (final Iterator<String> iterator = collection.iterator(); iterator.hasNext();) {
    buffer.append(iterator.next());
    if (iterator.hasNext()) {
        buffer.append(separator);
...
Stringjoin(final Collection list, final String separator)
Join a list of strings into a single string with a separator
final StringBuilder sb = new StringBuilder();
for (final String s : list) {
    if (sb.length() > 0) {
        sb.append(separator);
    sb.append(s);
return sb.toString();
...
Stringjoin(final Collection seq, final String delimiter)
join
if (null == seq || seq.size() < 1) {
    return "";
} else {
    StringBuilder aim = new StringBuilder();
    for (String one : seq) {
        if (null != delimiter && aim.length() > 0) {
            aim.append(delimiter);
        aim.append(one);
    return aim.toString();
Stringjoin(final Collection strs, final String delimiter)
join
if (strs == null || strs.isEmpty()) {
    return "";
Iterator<String> it = strs.iterator();
if (strs.size() == 1) {
    return it.next();
StringBuilder sb = new StringBuilder(it.next());
...