Java Utililty Methods List Join

List of utility methods to do List Join

Description

The list of methods to do List Join are organized into topic(s).

Method

Stringjoin(final List list)
Joins items of a text list, separating items by comma.
if (list == null) {
    return null;
} else if (list.size() == 0) {
    return "";
} else if (list.size() == 1) {
    return list.get(0);
final StringBuilder builder = new StringBuilder();
...
Stringjoin(final List list, final String sepa)
join
final StringBuilder text = new StringBuilder(256);
final int size = list.size();
for (int k = 0; k < size; k++) {
    text.append(list.get(k));
    if (k == size - 1) {
        break;
    text.append(sepa);
...
Stringjoin(final List path, final char delimiter)
join
StringBuilder builder = new StringBuilder();
for (String element : path) {
    if (builder.length() != 0) {
        builder.append(delimiter);
    builder.append(element);
return builder.toString();
...
Stringjoin(final List strings, final String delimiter)
Joins a list of strings to one string
assert strings != null;
if (strings.isEmpty()) {
    return "";
boolean first = true;
final StringBuilder builder = new StringBuilder();
for (final String string : strings) {
    if (!first) {
...
Stringjoin(final List strings, final String separator)
join
if (strings == null) {
    return "";
return join(strings.toArray(new String[strings.size()]), separator);
Stringjoin(final List substrings, final String join)
Joins a list of substrings with a join between each element
final StringBuilder sb = new StringBuilder();
for (final String substring : substrings) {
    if (sb.length() != 0) {
        sb.append(join);
    sb.append(substring);
return sb.toString();
...
Stringjoin(final String delimiter, List values)
Join values to string
final StringBuilder sb = new StringBuilder();
for (final Object v : values) {
    if (sb.length() > 0) {
        sb.append(delimiter);
    sb.append(v);
return sb.toString();
...
Stringjoin(final String separator, final List list)
join
final Iterator<String> it = list.iterator();
String result = "";
while (it.hasNext()) {
    result += it.next() + (it.hasNext() ? separator : "");
return result;
Stringjoin(final String with, final List array)
join
final StringBuffer buf = new StringBuffer();
for (final String s : array) {
    if (buf.length() > 0) {
        buf.append(with);
    buf.append(s);
return buf.toString();
...
Stringjoin(Iterable list)
join
assert list != null;
Iterator<String> iterator = list.iterator();
assert iterator.hasNext();
StringBuilder buf = new StringBuilder();
buf.append(iterator.next());
while (iterator.hasNext()) {
    buf.append(", ");
    buf.append(iterator.next());
...