Java Utililty Methods Collection to String

List of utility methods to do Collection to String

Description

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

Method

StringcollectionToString(Collection c, String delim)
collection To String
StringBuffer sb = new StringBuffer();
for (Iterator i = c.iterator(); i.hasNext();) {
    if (sb.length() > 0) {
        sb.append(delim);
    Object o = i.next();
    if (o != null) {
        sb.append(o.toString());
...
StringcollectionToString(Collection c, String spilt)
Formats a Date as a fifteen character long String made up of the Date's padded millisecond value.
if (c == null) {
    return null;
if (spilt == null) {
    return null;
String ret = "";
ArrayList a = new ArrayList(c);
...
StringcollectionToString(Collection col)
Prints each object in the collection with commas between them.
StringBuffer outputString = new StringBuffer(100);
boolean firstItem = true;
Iterator it = col.iterator();
while (it.hasNext()) {
    if (!firstItem)
        outputString.append(", ");
    outputString.append(it.next());
    firstItem = false;
...
StringcollectionToString(Collection coll)
Converts the given collection of objects to string as a comma-separated list.
if (coll == null) {
    return "<null>";
} else if (coll.isEmpty()) {
    return "<none>";
} else {
    StringBuilder s = new StringBuilder();
    Iterator iter = coll.iterator();
    while (iter.hasNext()) {
...
StringcollectionToString(Collection collection, String delim)
collection To String
if (collection == null) {
    return "NULL";
Iterator i = collection.iterator();
return iteratorToString(i, delim, null);
StringcollectionToString(Collection list, String split)
collection To String
if (isEmpty(split)) {
    split = ", ";
StringBuilder buf = new StringBuilder();
if (list != null && !list.isEmpty()) {
    Iterator iter = list.iterator();
    if (iter.hasNext()) {
        buf.append(iter.next());
...
StringcollectionToString(Collection set)
collection To String
return collectionToString(set, ",");
StringcollectionToString(Collection c)
collection To String
return arrayToString(c.toArray());
StringcollectionToString(Collection collection, String delimiter)
Converts all the objects from the collections to a string and separates them using a delimiter.
StringBuilder result = new StringBuilder();
List<Object> list = new ArrayList<>();
list.addAll(collection);
if (delimiter == null) {
    delimiter = ",";
for (Object obj : list) {
    result.append(obj.toString());
...
StringcollectionToString(Collection collection, String seperator)
collection To String
String result = "";
for (Iterator<? extends Object> iterator = collection.iterator(); iterator.hasNext();) {
    String string = iterator.next().toString();
    if (result.length() == 0)
        result += string;
    else
        result += seperator + string;
return result;