import java.util.*; import java.io.*; public class ListOfFiles implements Enumeration<FileInputStream> { private String[] listOfFiles; private int current = 0; public ListOfFiles(String[] listOfFiles) { this.listOfFiles = listOfFiles; } public boolean hasMoreElements() { return current < listOfFiles.length; } public FileInputStream nextElement() { FileInputStream in = null; if (!hasMoreElements()) throw new NoSuchElementException("No more files."); else { String nextElement = listOfFiles[current]; current++; try { in = new FileInputStream(nextElement); } catch (FileNotFoundException e) { System.err.println("ListOfFiles: Can't open " + nextElement); } } return in; } }