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

Stringconcat(List tokens, int start, int end, String joiner)
Joins the tokens from position start to position end, the size is end-start.
StringBuilder sb = new StringBuilder();
for (int i = start; i < end; i++) {
    if (i > start) {
        sb.append(joiner);
    sb.append(tokens.get(i));
return sb.toString();
...
StringconcatAndJoin(String sep, List data, String prefix, String suffix)
Concat a prefix and suffix to each element in a list, and join with a separator.
StringBuilder builder = new StringBuilder();
boolean first = true;
for (String str : data) {
    if (first) {
        first = false;
    } else {
        builder.append(sep);
    builder.append(prefix);
    builder.append(str);
    builder.append(suffix);
return builder.toString();
booleancontains(List joinParams, int joinIndex)
Checks if joinParams contain value joinIndex
boolean exists = false;
for (int i = 0; i < joinParams.size(); i++)
    if (joinParams.get(i) == joinIndex) {
        exists = true;
        break;
return exists;
ListgetJoinKeyValues(List tuple, List joinKeyIndices)
get Join Key Values
final ArrayList<String> values = new ArrayList<String>();
for (final int ind : joinKeyIndices) {
    final String val = tuple.get(ind);
    values.add(val);
return values;
Stringjoin(char separator, List seqs)
join
return join(Character.toString(separator), false, seqs);
CharSequencejoin(CharSequence delimiter, Iterable list)
join
Iterator<? extends CharSequence> it = list.iterator();
if (it.hasNext()) {
    StringBuilder sb = new StringBuilder(it.next());
    while (it.hasNext()) {
        sb.append(delimiter);
        sb.append(it.next());
    return sb.toString();
...
Stringjoin(CharSequence delimiter, List elements)
join
StringBuilder result = new StringBuilder();
for (int i = 0; i < elements.size(); i++) {
    result.append(elements.get(i));
    if (i != elements.size() - 1) {
        result.append(delimiter);
return result.toString();
...
Stringjoin(Collection list, String separator)
join
if (list == null) {
    return null;
Iterator<?> iterator = list.iterator();
Object first = iterator.next();
if (!iterator.hasNext()) {
    return valueOf(first);
StringBuffer buf = new StringBuffer(256); 
if (first != null) {
    buf.append(first);
while (iterator.hasNext()) {
    if (separator != null) {
        buf.append(separator);
    Object obj = iterator.next();
    if (obj != null) {
        buf.append(obj);
return buf.toString();
Stringjoin(Collection stringList, String seperator)
join
return join(stringList, seperator, "%s");
Stringjoin(Collection list, String delimiter)
Use this when you don't want to include Apache Common's string for plugins.
StringBuffer buffer = new StringBuffer();
for (String str : list) {
    buffer.append(str);
    buffer.append(delimiter);
return buffer.toString();