Java Utililty Methods Iterable to String

List of utility methods to do Iterable to String

Description

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

Method

StringtoString(Iterable names)
to String
Formatter formatter = new Formatter();
boolean first = true;
for (Object name : names) {
    if (first) {
        formatter.format("'%s'", name);
        first = false;
    } else {
        formatter.format(", '%s'", name);
...
StringtoString(Iterable iterable)
to String
String ret = "";
if (iterable != null) {
    int count = 0;
    for (String str : iterable) {
        if (count == 0)
            ret = str;
        else
            ret += (", " + str);
...
StringtoString(Iterable strs)
to String
StringBuilder ret = new StringBuilder();
for (Iterator<String> i = strs.iterator(); i.hasNext();) {
    ret.append(i.next());
    if (i.hasNext())
        ret.append(",");
return ret.toString();
StringtoString(Iterable iterable, String separator)
to String
final StringBuilder stringBuilder = new StringBuilder();
for (final Iterator<T> iterator = iterable.iterator(); iterator.hasNext();) {
    final T object = iterator.next();
    stringBuilder.append(object);
    if (iterator.hasNext()) {
        stringBuilder.append(separator);
return stringBuilder.toString();