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 items, String join)
Join elements of a String collection into a single string.
StringBuilder list = new StringBuilder();
boolean first = true;
for (String type : items) {
    if (!first) {
        list.append(join);
    list.append(type);
    first = false;
...
Stringjoin(Collection items, String prefix, String suffix, String itemPrefix, String itemSuffix)
join
StringBuilder sb = new StringBuilder();
sb.append(prefix);
for (String item : items) {
    sb.append(itemPrefix).append(item).append(itemSuffix);
sb.append(suffix);
return sb.toString();
Stringjoin(Collection list)
join
StringBuilder sb = new StringBuilder();
for (String s : list) {
    sb.append(s).append(' ');
if (sb.length() > 0) {
    sb.deleteCharAt(sb.length() - 1);
return sb.toString();
...
Stringjoin(Collection list, String conjunction)
join
StringBuilder sb = new StringBuilder();
if (conjunction == null) {
    conjunction = ", ";
if (list != null && !list.isEmpty()) {
    for (String string : list) {
        sb.append(string).append(conjunction);
    sb.setLength(sb.length() - conjunction.length());
return sb.toString();
Stringjoin(Collection packs)
join
final StringBuilder s = new StringBuilder();
for (final String pack : sorted(packs)) {
    s.append(", ").append(pack);
return s.length() > 0 ? s.substring(2) : s.toString();
Stringjoin(Collection s, String delimiter)
join
return join(s, delimiter, false);
Stringjoin(Collection s, String delimiter)
Join a collection of objects into a single string string separated by a delimiter
if (s.isEmpty())
    return "";
Iterator<String> iter = s.iterator();
StringBuffer buffer = new StringBuffer(iter.next());
while (iter.hasNext())
    buffer.append(delimiter).append(iter.next());
return buffer.toString();
Stringjoin(Collection src, String delim)
join
StringBuilder sb = new StringBuilder();
boolean first = true;
for (String s : src) {
    if (first) {
        first = false;
    } else {
        sb.append(delim);
    sb.append(s);
return sb.toString();
Stringjoin(Collection strings)
Joins a Collection of strings into a single string, inserting a space between each one.
return join(strings, " ");
Stringjoin(Collection strings, String delimiter)
Joins a Collection of String s in a single String using delimiter between each String .
StringBuffer buffer = new StringBuffer();
Iterator<String> iter = strings.iterator();
while (iter.hasNext()) {
    buffer.append(iter.next());
    if (iter.hasNext()) {
        buffer.append(delimiter);
return buffer.toString();