Java List to String convertListToString(Iterable l)

Here you can find the source of convertListToString(Iterable l)

Description

convert List To String

License

Apache License

Declaration

public static String convertListToString(Iterable<Long> l) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;

public class Main {
    public static String convertListToString(Iterable<Long> l) {
        return convertListToString(l, ", ");
    }/*from   w w w  . j a va2  s.  com*/

    public static String convertListToString(Iterable<Long> l, String separator) {
        if (separator == null)
            separator = ", ";

        StringBuilder buff = new StringBuilder();
        for (Iterator<Long> it = l.iterator(); it.hasNext();) {
            buff.append(it.next());
            if (it.hasNext()) {
                buff.append(separator);
            }
        }

        return buff.toString();
    }
}

Related

  1. asStringList(Collection list)
  2. asStringList(Collection objects)
  3. asStringList(List coll)
  4. asStringList(Set attributes)
  5. convertListToStrArray(List list)
  6. convertListToString(List list)
  7. convertListToString(List list, String delimiter, char encloser)
  8. convertListToString(List list)
  9. convertListToString(List data)

    HOME | Copyright © www.java2s.com 2016