Java Iterable Join join(Iterable iterable, String separator)

Here you can find the source of join(Iterable iterable, String separator)

Description

join

License

Open Source License

Declaration

public static <E> String join(Iterable<E> iterable, String separator) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Iterator;

public class Main {
    public static <E> String join(Iterable<E> iterable, String separator) {
        if (iterable == null)
            return null;
        Iterator<E> iterator = iterable.iterator();
        StringBuffer buf = new StringBuffer(256);
        while (iterator.hasNext()) {
            E elem = iterator.next();//from   w  ww  .  j a  v a 2  s.com
            if (elem != null)
                buf.append(elem);
            if (iterator.hasNext())
                buf.append(separator);
        }
        return buf.toString();
    }
}

Related

  1. join(Iterable list, String delimiter)
  2. join(Iterable objects)
  3. join(Iterable objects, String delimiter)
  4. join(Iterable parts, String delimiter)
  5. join(Iterable target, String separator)
  6. join(Iterable array)
  7. join(Iterable items, String separator)
  8. join(Iterable iterable, String delimiter)
  9. join(Iterable s, String delimiter)