mjc

org.multijava.util.testing
Class FileIterator

java.lang.Object
  extended byorg.multijava.util.testing.FileIterator
All Implemented Interfaces:
Iterator

public class FileIterator
extends Object
implements Iterator

This is a utility class that is an iterator over the lines produced by reading a file. It is used in particular by various JUnit tests.

Author:
David R. Cok

Field Summary
private  String nextLine
          The next value to be returned by the iterator.
private  BufferedReader r
          A reader that reads lines from the file.
 
Constructor Summary
FileIterator(String filename)
          Starts an iterator reading from the given external process.
 
Method Summary
 boolean hasNext()
          Per a standard iterator, returns true if there is another value waiting.
 Object next()
          Per a standard iterator, returns the next value - and throws java.util.NoSuchElementException if the list has been exhausted (hasNext() returns false).
 void remove()
          This operation will throw an exception, as there is no need for remove in this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

r

private BufferedReader r
A reader that reads lines from the file.


nextLine

private String nextLine
The next value to be returned by the iterator. We read ahead one so that we know the value of hasNext() when asked.

Constructor Detail

FileIterator

public FileIterator(String filename)
             throws IOException
Starts an iterator reading from the given external process.

Throws:
IOException
Method Detail

hasNext

public boolean hasNext()
Per a standard iterator, returns true if there is another value waiting.

Specified by:
hasNext in interface Iterator

next

public Object next()
Per a standard iterator, returns the next value - and throws java.util.NoSuchElementException if the list has been exhausted (hasNext() returns false).

Specified by:
next in interface Iterator

remove

public void remove()
This operation will throw an exception, as there is no need for remove in this context.

Specified by:
remove in interface Iterator

mjc

mjc is Copyright (C) 2000-2004 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. mjc is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.