Here you can find the source of printIterator(Iterator i, String header)
public static void printIterator(Iterator i, String header)
//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 © 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(); } }