Java Iterator printIterator(Iterator i, String header)

Here you can find the source of printIterator(Iterator i, String header)

Description

print Iterator

License

Mozilla Public License

Declaration

public static void printIterator(Iterator i, String header) 

Method Source Code


//package com.java2s;
/*//from   w  ww  . j  a  v a 2s . c  om
 * Util.java
 *
 * Created on March 30, 2007, 11:41 AM
 *
 * <p><b>License and Copyright: </b>The contents of this file are subject to the
 * Mozilla Public License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of the License
 * at <a href="http://www.mozilla.org/MPL">http://www.mozilla.org/MPL/.</a></p>
 *
 * <p>Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.</p>
 *
 * <p>The entire file consists of original code.  Copyright &copy; 2003-2007
 * Tufts University. All rights reserved.</p>
 *
 * -----------------------------------------------------------------------------
 */

import java.util.*;

import java.util.*;

public class Main {
    public static void printIterator(Iterator i, String header) {
        System.out.println(header);
        for (int c = 0; c < header.length(); c++)
            System.out.print("=");
        System.out.println();

        if (i.hasNext()) {
            while (i.hasNext())
                System.out.println(i.next());
        } else
            System.out.println("<EMPTY>");

        System.out.println();
    }
}

Related

  1. multiSetIterator(Iterator... iterable)
  2. nextPermutation(Iterator> it)
  3. printContainer(Iterator it, String sep)
  4. printElements(String desc, Iterator i)
  5. printIterator(final Iterator iterator)
  6. printIterator(Iterator> it)
  7. put(String key, Iterator value)
  8. putAllFromAll(Map map, Iterator> mapsIterator)
  9. read(Iterator it, E[] array)