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

StringjoinStrings(Iterable list)
same as #joinStrings(Iterable,String) , and default sep to empty string
return joinStrings(list, "");
StringjoinStrings(List aList, String aString)
Returns a string by concatenating strings in given list separated by given string.
StringBuffer sb = new StringBuffer();
for (int i = 0, iMax = aList.size(); i < iMax; i++)
    sb.append(i == 0 ? "" : aString).append(aList.get(i));
return sb.toString();
StringjoinStrings(List list, String delim)
This method takes a List and a delimiter and joins the strings into a single string, where the original strings are separated using the given delimiter.
if (list == null)
    return null;
StringBuilder builder = new StringBuilder(list.get(0));
for (String s : list.subList(1, list.size())) {
    builder.append(delim).append(s);
return builder.toString();
StringjoinStrings(List strings, String separator)
Join an arraylist of strings into a single string using a separator
if (strings == null) {
    return null;
String res = ""; 
for (int i = 0; i < strings.size(); i++) {
    res += (i > 0) ? separator : ""; 
    res += strings.get(i);
return res;
StringjoinStrings(List strings, String separator)
Join the strings in strings together in sequence with separator between them.
if (strings == null || separator == null) {
    throw new NullPointerException();
if (strings.isEmpty()) {
    return "";
StringBuilder builder = new StringBuilder(strings.get(0));
for (String element : strings.subList(1, strings.size())) {
...
StringjoinStrings(String delim, List strings)
join Strings
StringBuilder sb = new StringBuilder();
for (int i = 0; i < strings.size(); ++i) {
    sb.append(strings.get(i).toString());
    if (i < strings.size() - 1) {
        sb.append(delim);
return sb.toString();
...
StringjoinStrings(String joiner, List objects)
join Strings
return joinStrings(joiner, objects, false);
StringjoinTextWithCommas(List list)
join Text With Commas
StringBuffer buf = new StringBuffer();
if (list.size() > 0) {
    Iterator<String> iterator = list.iterator();
    for (int i = 0; iterator.hasNext(); i++) {
        String field = iterator.next();
        buf.append(field);
        if (i < list.size())
            buf.append(", ");
...
booleanjoinThreads(List threads)
join Threads
boolean interrupted = false;
for (Thread curThread : threads) {
    try {
        curThread.join();
    } catch (InterruptedException e) {
        e.printStackTrace();
        interrupted = true;
        break;
...
StringBufferjoinTokens(final List tokens)
Crudely join tokens together.
final StringBuffer sb = new StringBuffer();
for (final String token : tokens) {
    sb.append(token);
    sb.append(" ");
return sb;