Java Iterator Join join(Iterator iterator, String s)

Here you can find the source of join(Iterator iterator, String s)

Description

join

License

Apache License

Declaration

public static String join(Iterator iterator, String s) 

Method Source Code

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

import java.util.Arrays;
import java.util.Iterator;

public class Main {
    public static String join(Object aobj[], String s) {
        return join(Arrays.asList(aobj).iterator(), s);
    }// w  w w . j a va  2 s. co  m

    public static String join(Iterator iterator, String s) {
        StringBuffer stringbuffer = new StringBuffer();
        do {
            if (!iterator.hasNext())
                break;
            stringbuffer.append(iterator.next());
            if (iterator.hasNext())
                stringbuffer.append(s);
        } while (true);
        return stringbuffer.toString();
    }
}

Related

  1. join(Iterator iterator, String separator)
  2. join(Iterator iterator, String separator)
  3. join(Iterator objects, String separator)
  4. join(Iterator iterator, String separator)