public class InputIt extends java.lang.Object implements FileIt<java.lang.String>
Class InputIt is a buffered iterator whose next()
method returns lines of a text input stream.
If an IOException is thrown when an InputIt
instance reads from the text input stream, the IOException
is trapped, an error message is written to standard out, and the
Java Virtual Machine is terminated.
InputIt are not thread-safe.DEFAULT_BUFFER_SIZE| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
The default buffer size, which is 4,194,304 bytes.
|
| Modifier and Type | Method and 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. |
static InputIt |
fromGzipFile(java.io.File file)
Constructs and returns an
InputIt instance with the default
buffer size that iterates through lines of the specified compressed
or uncompressed text file. |
static InputIt |
fromGzipFile(java.io.File file,
int bufferSize)
Constructs and returns an
InputIt instance with the specified
buffer size that iterates through lines of the specified compressed
or uncompressed text file. |
static InputIt |
fromStdIn()
Constructs and returns an
InputIt instance with the default
buffer size that iterates through lines of text read from standard input. |
static InputIt |
fromStdIn(int bufferSize)
Constructs and returns an
InputIt instance with the specified
buffer size that iterates through lines of text read from standard input. |
static InputIt |
fromTextFile(java.io.File file)
Constructs and returns an
InputIt instance with the default
buffer size that iterates through lines of the specified text file. |
static InputIt |
fromTextFile(java.io.File file,
int bufferSize)
Constructs and returns an
InputIt instance with the specified
buffer size that iterates through lines of the specified text file. |
boolean |
hasNext()
Returns
true if the iteration has more elements. |
java.lang.String |
next()
Returns the next element in the iteration.
|
void |
remove()
The
remove method is not supported by this iterator. |
java.lang.String |
toString()
Returns a string representation of this iterator.
|
public static final int DEFAULT_BUFFER_SIZE
public java.io.File file()
FileItnull if the data are read from standard input or are
computed data.public boolean hasNext()
true if the iteration has more elements.hasNext in interface java.util.Iterator<java.lang.String>true if the iteration has more elementspublic java.lang.String next()
next in interface java.util.Iterator<java.lang.String>java.util.NoSuchElementException - if the iteration has no more elementspublic void remove()
remove method is not supported by this iterator.remove in interface java.util.Iterator<java.lang.String>java.lang.UnsupportedOperationException - if this method is invokedpublic void close()
FileItclose, further
invocations of close() have no effect.public java.lang.String toString()
public static InputIt fromStdIn()
InputIt instance with the default
buffer size that iterates through lines of text read from standard input.InputIt instance that iterates
through lines of text read from standard inputpublic static InputIt fromStdIn(int bufferSize)
InputIt instance with the specified
buffer size that iterates through lines of text read from standard input.bufferSize - the buffer size in bytesInputIt instance that iterates
through lines of text read from standard inputjava.lang.IllegalArgumentException - if bufferSize < 0public static InputIt fromGzipFile(java.io.File file)
InputIt instance with the default
buffer size that iterates through lines of the specified compressed
or uncompressed text file. If the filename ends in ".gz", the file
must be either BGZIP-compressed or GZIP-compressed.file - a compressed or uncompressed text fileInputIt instance that iterates
through lines of the specified text filejava.lang.NullPointerException - if file == nullpublic static InputIt fromGzipFile(java.io.File file, int bufferSize)
InputIt instance with the specified
buffer size that iterates through lines of the specified compressed
or uncompressed text file. If the filename ends in ".gz", the file must
be either BGZIP-compressed or GZIP-compressed.file - a compressed or uncompressed text filebufferSize - the buffer size in bytesInputIt instance that iterates
through lines of the specified text filejava.lang.IllegalArgumentException - if bufferSize < 0java.lang.NullPointerException - if file == nullpublic static InputIt fromTextFile(java.io.File file)
InputIt instance with the default
buffer size that iterates through lines of the specified text file.file - a text fileInputIt instance that iterates through
lines of the specified text filejava.lang.NullPointerException - if filename == nullpublic static InputIt fromTextFile(java.io.File file, int bufferSize)
InputIt instance with the specified
buffer size that iterates through lines of the specified text file.file - a text filebufferSize - the buffer size in bytesInputIt instance that iterates through
lines of the specified text filejava.lang.IllegalArgumentException - if bufferSize < 0java.lang.NullPointerException - if filename == null