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 of read(), or readLine().
    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 by read()
    boolean isClosed()
    Get if the buffer has been closed.
    int lookAhead()
    Peek at the next character that will be returned by read() without consuming it.
    int read()
    Read a single character from the underlying reader.
    String readLine()
    Reads a line of text.

    Methods inherited from interface java.io.Closeable

    close

    Methods inherited from interface java.lang.Readable

    read
  • Method Details

    • getLastChar

      int getLastChar()
      Get the last character returned by read()
      Returns:
      the last character returned
    • read

      int read() throws IOException
      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

      String readLine() throws IOException
      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

      int lookAhead() throws IOException
      Peek at the next character that will be returned by read() 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 of read(), or readLine().
      Returns:
      the byte position
    • isClosed

      boolean isClosed()
      Get if the buffer has been closed.
      Returns:
      true if the buffer has been closed