java.io.Closeable, java.lang.AutoCloseablepublic class LineNumberScanner
extends java.lang.Object
implements java.io.Closeable, java.lang.AutoCloseable
| Constructor | Description |
|---|---|
LineNumberScanner(java.io.Reader reader,
java.lang.String delimiter) |
Creates a new
LineNumberScanner using the given reader as underlying source. |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
@Nullable java.lang.String |
getCurrentLine() |
Gets the full line containing the last token read.
|
int |
getLineNumber() |
Gets the line number of the last token read.
|
double |
nextDouble() |
Scans the next token of the input as a double.
|
int |
nextInt() |
Scans the next token of the input as an int.
|
java.lang.String |
nextLine() |
Reads and returns the next line of input.
|
java.lang.String[] |
nextLineTokens() |
Reads and returns the next line of input as an array of string tokens.
|
java.lang.String |
nextString() |
Scans the next token of the input as a string.
|
public LineNumberScanner(java.io.Reader reader,
java.lang.String delimiter)
LineNumberScanner using the given reader as underlying source.reader - the reader to read the data fromdelimiter - the delimiter to use to identify separate tokenspublic int getLineNumber()
Note that this method does not move the scanner or consume any input.
@Nullable public @Nullable java.lang.String getCurrentLine()
Note that this method does not move the scanner or consume any input.
public java.lang.String nextString()
throws InputParsingException
NoMoreLinesToReadException - if there is no more lines to readInputParsingException - if an error occurs while reading the inputpublic int nextInt()
throws InputParsingException
NoMoreLinesToReadException - if there is no more lines to readInputParsingException - if the input could not be parsed as an intpublic double nextDouble()
throws InputParsingException
NoMoreLinesToReadException - if there is no more lines to readInputParsingException - if the input could not be parsed as an intpublic java.lang.String nextLine()
throws InputParsingException
IncompleteLineReadException - if the previous line was not completely consumedNoMoreLinesToReadException - if there is no more lines to readInputParsingException - if an error occurs while reading the inputpublic java.lang.String[] nextLineTokens()
throws InputParsingException
IncompleteLineReadException - if the previous line was not completely consumedNoMoreLinesToReadException - if there is no more lines to readInputParsingException - if an error occurs while reading the inputpublic void close()
close in interface java.lang.AutoCloseableclose in interface java.io.Closeable