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(final Collection collection, final String recordSeparator)
collection To String
final StringBuilder sb = new StringBuilder();
if (collection != null) {
    for (final Iterator iterator = collection.iterator(); iterator.hasNext();) {
        final Object obj = iterator.next();
        if (obj != null) {
            sb.append(obj.toString());
            if (iterator.hasNext()) {
                sb.append(recordSeparator);
...
StringcollectionToString(final Collection aCol, final String aSepLines)
collection To String
StringBuilder wRes = new StringBuilder(2048);
Iterator<?> wIt = aCol.iterator();
while (wIt.hasNext()) {
    if (wRes.length() != 0) {
        wRes.append(aSepLines);
    Object wObj = wIt.next();
    if (wObj == null) {
...
StringcollectionToString(final Collection c)
Converts a Collection into a String
final Iterator<?> iter = c == null ? null : c.iterator();
if (!hasNext(iter)) {
    return null;
final StringBuilder sb = new StringBuilder();
for (; iter.hasNext();) {
    final String s = toString(iter.next());
    if (s != null) {
...
StringcollectionToString(final Collection collection, final String separator)
Creates a string representation of the elements in the collection separated by separator.
StringBuilder sb = new StringBuilder();
for (Iterator<?> iter = collection.iterator(); iter.hasNext();) {
    sb.append(iter.next());
    if (iter.hasNext()) {
        sb.append(separator);
return sb.toString();
...
StringcollectionToString(final Collection elements, final String separator)
collection To String
String result = "";
final Iterator<?> iterator = elements.iterator();
while (iterator.hasNext()) {
    final Object object = iterator.next();
    result += object.toString();
    if (iterator.hasNext())
        result += separator;
return result;
StringcollectionToString(final String separator, final Collection coll)
collection To String
final StringBuffer buf = new StringBuffer();
final Iterator<?> it = coll.iterator();
while (it.hasNext()) {
    final Object item = it.next();
    if (item == null) {
        buf.append("null");
    } else {
        buf.append(item.toString());
...
StringcollectionToString(Iterable c)
Create a string representation of an iterable collection
StringBuilder b = new StringBuilder();
b.append("[");
Iterator<T> it = c.iterator();
while (it.hasNext()) {
    b.append(it.next());
    if (it.hasNext())
        b.append(",");
b.append("]");
return b.toString();
StringcollectionToString(Object[] objects)
collection To String
String s = "";
for (int i = 0; i < objects.length; i++) {
    s += objects[i].toString();
    if (i < objects.length - 1) {
        s += ", ";
return s;
...
StringcollectionToString(String prefix, Collection list)
collection To String
if (list == null)
    return "null";
StringBuilder sb = new StringBuilder();
sb.append(prefix);
sb.append('[');
boolean first = true;
for (Object item : list) {
    if (!first) {
...
String[]collectionToStringArray(Collection holder)
{ method
String[] ret = new String[holder.size()];
holder.toArray(ret);
return (ret);