Package blbutil
Class InputIt
java.lang.Object
blbutil.InputIt
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.-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops reading data elements and releases any system resources that are held by this object.file()Returns the file from which the data are read, ornullif the data are read from standard input or if the data source is unknown.static InputItfromGzipFile(File file) Constructs and returns anInputItinstance with the default buffer size that iterates through lines of the specified compressed or uncompressed text file.static InputItfromGzipFile(File file, int bufferSize) Constructs and returns anInputItinstance with the specified buffer size that iterates through lines of the specified compressed or uncompressed text file.static InputItConstructs and returns anInputItinstance with the default buffer size that iterates through lines of text read from standard input.static InputItfromStdIn(int bufferSize) Constructs and returns anInputItinstance with the specified buffer size that iterates through lines of text read from standard input.static InputItfromTextFile(File file) Constructs and returns anInputItinstance with the default buffer size that iterates through lines of the specified text file.static InputItfromTextFile(File file, int bufferSize) Constructs and returns anInputItinstance with the specified buffer size that iterates through lines of the specified text file.booleanhasNext()Returnstrueif the iteration has more elements.next()Returns the next element in the iteration.voidremove()Theremovemethod is not supported by this iterator.toString()Returns a string representation of this iterator.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Method Details
-
file
Description copied from interface:FileItReturns the file from which the data are read, ornullif the data are read from standard input or if the data source is unknown. -
hasNext
public boolean hasNext()Returnstrueif the iteration has more elements. -
next
Returns the next element in the iteration.- Specified by:
nextin interfaceIterator<String>- Returns:
- the next element in the iteration
- Throws:
NoSuchElementException- if the iteration has no more elements
-
remove
public void remove()Theremovemethod is not supported by this iterator.- Specified by:
removein interfaceIterator<String>- Throws:
UnsupportedOperationException- if this method is invoked
-
close
public void close()Description copied from interface:FileItStops reading data elements and releases any system resources that are held by this object. Buffered data elements may remain accessible via thehasNext()andnext()methods after invokingclose(). After invokingclose(), further invocations ofclose()have no effect. -
toString
Returns a string representation of this iterator. The exact details of the representation are unspecified and subject to change. -
fromStdIn
Constructs and returns anInputItinstance with the default buffer size that iterates through lines of text read from standard input.- Returns:
- a new
InputItinstance that iterates through lines of text read from standard input
-
fromStdIn
Constructs and returns anInputItinstance with the specified buffer size that iterates through lines of text read from standard input.- Parameters:
bufferSize- the buffer size in bytes- Returns:
- a new
InputItinstance that iterates through lines of text read from standard input - Throws:
IllegalArgumentException- ifbufferSize < 0
-
fromGzipFile
Constructs and returns anInputItinstance 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.- Parameters:
file- a compressed or uncompressed text file- Returns:
- a new
InputItinstance that iterates through lines of the specified text file - Throws:
NullPointerException- iffile == null
-
fromGzipFile
Constructs and returns anInputItinstance 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.- Parameters:
file- a compressed or uncompressed text filebufferSize- the buffer size in bytes- Returns:
- a new
InputItinstance that iterates through lines of the specified text file - Throws:
IllegalArgumentException- ifbufferSize < 0NullPointerException- iffile == null
-
fromTextFile
Constructs and returns anInputItinstance with the default buffer size that iterates through lines of the specified text file.- Parameters:
file- a text file- Returns:
- a new
InputItinstance that iterates through lines of the specified text file - Throws:
NullPointerException- iffilename == null
-
fromTextFile
Constructs and returns anInputItinstance with the specified buffer size that iterates through lines of the specified text file.- Parameters:
file- a text filebufferSize- the buffer size in bytes- Returns:
- a new
InputItinstance that iterates through lines of the specified text file - Throws:
IllegalArgumentException- ifbufferSize < 0NullPointerException- iffilename == null
-