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

StringjoinLong(List lst, String prefix)
join Long
final StringBuilder sb = new StringBuilder();
String separator = "";
for (Long f : lst) {
    sb.append(separator);
    separator = prefix;
    sb.append(f);
return sb.toString();
...
StringjoinNiceString(List strings)
join Nice String
StringBuilder stringbuilder = new StringBuilder();
int i = 0;
for (String s : strings) {
    if (i > 0) {
        if (i == strings.size() - 1) {
            stringbuilder.append(" and ");
        } else {
            stringbuilder.append(", ");
...
ListjoinRecords(List first, List second, String key)
check each element of first list, and compare it to each element of second list.
if (first != null && second != null) {
    for (int i = 0; i < first.size(); i++) {
        Map record1 = (Map) first.get(i);
        for (Iterator iterator1 = second.iterator(); iterator1.hasNext();) {
            Map record2 = (Map) iterator1.next();
            if (record2.get(key) != null && record2.get(key).equals(record1.get(key))) {
                record1.putAll(record2);
                break;
...
StringjoinRelativePath(List components)
Construct a relative path from the given components
StringBuilder builder = new StringBuilder();
for (String component : components) {
    if (builder.length() > 0)
        builder.append('/');
    builder.append(component);
return builder.toString();
CharSequencejoinSegments(List segments, int startIndex, int endIndex)
Joins segments from startIndex to endIndex-1.
StringBuilder sb = new StringBuilder();
appendSegments(sb, segments, startIndex, endIndex);
return sb;
StringjoinString(java.util.List values, String delimiter)
join String
StringBuffer s = new StringBuffer();
boolean first = true;
for (String v : values) {
    if (!first) {
        s.append(delimiter);
    s.append(v);
    first = false;
...
StringjoinString(List array, String symbol)
join String
String result = "";
if (array != null) {
    for (int i = 0; i < array.size(); i++) {
        String temp = array.get(i).toString();
        if (temp != null && temp.trim().length() > 0)
            result += (temp + symbol);
    if (result.length() > 1)
...
StringjoinString(List objs, String separator)
Create a string for a list of objects, with a specified separator, e.g.
String s = "";
boolean first = true;
for (Object obj : objs) {
    if (first) {
        first = false;
    } else {
        s += separator;
    s += obj.toString();
return s;
StringjoinString(List val, String delim)
join String
StringBuilder builder = new StringBuilder();
for (String l : val) {
    builder.append(l);
    builder.append(",");
return builder.toString().substring(0, builder.toString().length() - 1);
StringjoinStringList(String delimiter, List stringList)
join String List
String result = "";
boolean isFirst = true;
for (String s : stringList) {
    if (!isFirst) {
        result = result + delimiter;
    isFirst = false;
    result = result + s;
...