Package org.apache.commons.csv
Interface LineOrientedReader
- All Superinterfaces:
AutoCloseable
,Closeable
,Readable
- All Known Implementing Classes:
LineOrientedBufferedReader
public interface LineOrientedReader extends Readable, Closeable
An interface describing a
Readable
that supports line oriented parsing.-
Method Summary
Modifier and Type Method Description int
getBytePosition()
Get the byte position into the underlying buffer immediately after the last character returned by any flavor ofread()
, orreadLine()
.long
getCharacterPosition()
Get the current character position into the stream.long
getCurrentLineNumber()
Get the total number of total lines read.int
getLastChar()
Get the last character returned byread()
boolean
isClosed()
Get if the buffer has been closed.int
lookAhead()
Peek at the next character that will be returned byread()
without consuming it.int
read()
Read a single character from the underlying reader.String
readLine()
Reads a line of text.
-
Method Details
-
getLastChar
int getLastChar()Get the last character returned byread()
- Returns:
- the last character returned
-
read
Read a single character from the underlying reader. This method will only return characters if there is at least one complete line (terminated by a \r or \n character- Returns:
- The next character in the stream or -1 if there is not a complete line available.
- Throws:
IOException
- If the underlying read fails.
-
readLine
Reads a line of text. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed by a line feed.- Returns:
- A String containing the contents of the line, not including any line-termination characters, or null if the end of the stream has been reached
- Throws:
IOException
- If an I/O error occurs- See Also:
Files.readAllLines(java.nio.file.Path, java.nio.charset.Charset)
-
lookAhead
Peek at the next character that will be returned byread()
without consuming it.- Returns:
- the next character that will be read
- Throws:
IOException
- if a problem occurs refilling the underlying buffer
-
getCurrentLineNumber
long getCurrentLineNumber()Get the total number of total lines read.- Returns:
- the number of total lines read
-
getCharacterPosition
long getCharacterPosition()Get the current character position into the stream.- Returns:
- the current character position
-
getBytePosition
int getBytePosition()Get the byte position into the underlying buffer immediately after the last character returned by any flavor ofread()
, orreadLine()
.- Returns:
- the byte position
-
isClosed
boolean isClosed()Get if the buffer has been closed.- Returns:
- true if the buffer has been closed
-