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

Listjoin(List command, List args)
join
try {
    args.addAll(0, command);
    return args;
} catch (Exception e) {
    ArrayList<String> commands = new ArrayList<String>(args.size() + command.size());
    commands.addAll(command);
    commands.addAll(args);
    return commands;
...
Stringjoin(List elements)
join
if (elements.isEmpty())
    return "[]";
StringBuilder ret = new StringBuilder();
for (String element : elements)
    ret.append(", ").append(element);
return "[" + ret.substring(2) + "]";
Stringjoin(List items, char separator)
Creates a backslash escaped string, joining all the items.
StringBuilder sb = new StringBuilder(items.size() << 3);
boolean first = true;
for (String item : items) {
    if (first) {
        first = false;
    } else {
        sb.append(separator);
    for (int i = 0; i < item.length(); i++) {
        char ch = item.charAt(i);
        if (ch == '\\' || ch == separator) {
            sb.append('\\');
        sb.append(ch);
return sb.toString();
Stringjoin(List l, String joiner)
join a string list into a single string
StringBuilder sb = new StringBuilder();
boolean start = true;
for (String s : l) {
    if (start) {
        start = false;
    } else {
        sb.append(joiner);
    sb.append(s);
return sb.toString();
Stringjoin(List lines, char delim)
join
StringBuilder sb = new StringBuilder();
for (String string : lines) {
    sb.append(string);
    sb.append(delim);
return sb.toString();
Stringjoin(List list)
join
return join(list, null);
Stringjoin(List list)
join
return join(list, getDefaultSeparator());
Stringjoin(List list)
join
String rtn;
if (list.isEmpty()) {
    rtn = "";
} else {
    StringBuilder sb = new StringBuilder();
    for (String string : list) {
        sb.append(string).append(",");
    rtn = sb.substring(0, sb.length() - 1);
return rtn;
Stringjoin(List list)
Joins the given list into a comma-separated string.
if (list == null)
    return null;
StringBuilder joined = new StringBuilder();
boolean first = true;
for (String element : list) {
    if (first)
        first = false;
    else
...
Stringjoin(List list)
join
return join(list, " ");