E
- the type of the elements returned by this iterator's
next()
method.java.lang.AutoCloseable
, java.io.Closeable
, java.util.Iterator<E>
SampleFileIt<E>
public interface FileIt<E>
extends java.util.Iterator<E>, java.io.Closeable
An iterator for data elements in a file. If an IOExceptions is thrown while
reading a file, the IOException is trapped, an appropriate error message
is written to standard out, and the Java Virtual Machine is
terminated. The Iterator.remove()
method is unsupported
and throws an UnsupportedOperationException
.
FileIterator
object is no longer needed,
the close()
method should be invoked to release any
system resources controlled by the object. After calling close()
,
invoking hasNext()
returns false
, and invoking
next()
will throw a NoSuchElementException
.Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Terminates the iteration and releases any system resources that
are held by this object.
|
java.io.File |
file() |
Returns the file from which the data are read, or
null if the data are read from standard input or are
computed data. |
java.lang.String |
toString() |
Returns a string representation of
this . |
java.io.File file()
null
if the data are read from standard input or are
computed data.null
if the data are read from standard input or are
computed datavoid close()
close()
, further
invocations of close()
have no effect.close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.lang.String toString()
this
. The exact
details of the representation are unspecified and subject to change.toString
in class java.lang.Object
this