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

StringjoinColumnArray(List columnArray)
join Column Array
if (columnArray == null || columnArray.size() == 0) {
    return null;
StringBuilder column = new StringBuilder();
int columnSize = columnArray.size();
for (int i = 0; i < columnSize; i++) {
    column.append(columnArray.get(i));
    if (i + 1 < columnSize) {
...
StringjoinCommaAnd(List objs)
Returns a comma separated list, but the last comma is an "and".
int size = objs.size();
if (size == 0) {
    return "";
} else if (size == 1) {
    return objs.get(0).toString();
} else {
    StringBuilder sb = new StringBuilder();
    Iterator<T> iter = objs.iterator();
...
StringjoinCommaSeparatedList(List list)
Joins a list of Strings to a comma separated single String.
return joinList(list, ", ");
StringjoinDoubles(List list)
join Doubles
String joined = "";
for (double item : list) {
    joined += item + " ";
return joined.trim();
StringjoinIntegers(List integers, String token)
join Integers
if (integers == null || integers.isEmpty()) {
    return "";
StringBuilder buffer = new StringBuilder();
boolean appendToken = false;
for (Integer integer : integers) {
    if (appendToken) {
        buffer.append(token);
...
StringBuilderjoinLines(List lines)
join Lines
StringBuilder builder = new StringBuilder();
for (String line : lines) {
    builder.append(line);
return builder;
StringjoinLinesWithImplicitFinalLine(final List lines)
Joins the specified collection of lines into a string when the final line is implicitly specified.
final StringBuilder sb = new StringBuilder();
for (final CharSequence line : lines) {
    sb.append(line);
    sb.append('\n');
return sb.toString();
StringjoinList(final List list)
Joins the elements using comma as a separator.
if (list == null) {
    return null;
return join(list.toArray(new String[0]), ",");
StringjoinList(final List list, final String sep)
Given a list and some separator string, create a string with the entries in the list joined with the separator.
StringBuilder str = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
    str.append(list.get(i).toString());
    if (i < list.size() - 1) {
        str.append(sep);
return str.toString();
...
StringjoinList(List list, String separator)
join List
StringBuilder result = new StringBuilder();
for (Object o : list) {
    if (o == null || o.equals(""))
        continue;
    result.append(o.toString()).append(separator);
int i = result.lastIndexOf(separator);
if (i >= 0) {
...