Java Iterable to String iterableToString(Iterable list)

Here you can find the source of iterableToString(Iterable list)

Description

iterable To String

License

MIT License

Declaration

public static String iterableToString(Iterable<?> list) 

Method Source Code

//package com.java2s;
/*//from   w  w  w . ja  va2s  .  c  o  m
 * oxTrust is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

public class Main {
    public static String iterableToString(Iterable<?> list) {
        if (list == null) {
            return "";
        }

        StringBuilder sb = new StringBuilder();
        for (Object item : list) {
            sb.append(item);
            sb.append(",");
        }
        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }
}

Related

  1. iterableAsString(Iterable chars)
  2. iterableToString(Iterable iterable)
  3. iterableToString(Iterable charSequenceIterable)
  4. iterableToString(Iterable itrbl)
  5. iterableToString(Iterable objects, int limit)
  6. toString(final Iterable iterable, final CharSequence delimiter)