Java Utililty Methods Collection Join

List of utility methods to do Collection Join

Description

The list of methods to do Collection Join are organized into topic(s).

Method

Stringjoin(Collection data)
Join the given Collection using the DEFAULT_DELIMITER.
return join(data, DEFAULT_DELIMITER);
Stringjoin(Collection elements, String separator)
join
if (elements == null) {
    throw new NullPointerException();
if (separator == null) {
    separator = "";
boolean first = true;
StringBuilder stringBuilder = new StringBuilder();
...
Stringjoin(Collection items)
join
StringBuilder result = new StringBuilder();
boolean first = true;
for (Object o : items) {
    if (!first) {
        result.append(",");
    if (o != null) {
        result.append(o);
...
Stringjoin(Collection list, char separator)
join
if (list == null) {
    return "";
int size = list.size();
if (size == 0) {
    return "";
final StringBuilder sb = new StringBuilder();
...
Stringjoin(Collection lst, String delim)
joins a list into a string.
return joinCol(lst, delim);
Stringjoin(Collection objects, String glue)
same thing as perl's join()
StringBuilder builder = new StringBuilder();
for (Object o : objects) {
    builder.append(o);
    builder.append(glue);
builder.setLength(builder.length() - 1);
return builder.toString();
Stringjoin(Collection paramCollection, String paramString)
join
StringBuffer localStringBuffer = new StringBuffer();
while (paramCollection.iterator().hasNext()) {
    localStringBuffer.append("'" + paramCollection.iterator().next() + "'");
    if (!paramCollection.iterator().hasNext())
        continue;
    localStringBuffer.append(paramString);
return localStringBuffer.toString();
...
Stringjoin(Collection parts, String sep)
join
StringBuffer sb = new StringBuffer();
int counter = 0;
for (Object o : parts) {
    if (counter != 0) {
        sb.append(sep);
    sb.append(o);
    counter++;
...
Stringjoin(Collection s, String delimiter)
Join a collection, akin to Perl's join(), using a given delimiter to produce a single String
if (s == null) {
    throw new IllegalArgumentException("Collection to join must not be null");
StringBuffer buffer = new StringBuffer();
Iterator iter = s.iterator();
while (iter.hasNext()) {
    buffer.append(iter.next());
    if (iter.hasNext() && delimiter != null) {
...
Stringjoin(Collection s, String delimiter, boolean doQuote)
Join the Collection of Strings using the specified delimter and optionally quoting each
StringBuffer buffer = new StringBuffer();
Iterator iter = s.iterator();
while (iter.hasNext()) {
    if (doQuote) {
        buffer.append("\"" + iter.next() + "\"");
    } else {
        buffer.append(iter.next());
    if (iter.hasNext()) {
        buffer.append(delimiter);
return buffer.toString();