import java.util.*; import java.io.*; public class Driver { public static void main(String [] args) throws IOException { BufferedReader inFile = new BufferedReader(new FileReader("candy.txt")); BagArrayList bag = new BagArrayList(); // read the input file to intialize the bag while (true) { String name = inFile.readLine(); if (name == null) break; bag.add(new Item(name)); } // Now dump out the contents of the bag, using the iterator Iterator it = bag.bagIterator(); while (it.hasNext()) System.out.println("Eating a(n) " + it.next()); } }