Class NewlineInput

All Implemented Interfaces:
Closeable, AutoCloseable

public final class NewlineInput extends TextInput
This class provides a convenient access to text input. System dependent line breaks (\r\n, \n, \r) will be normalized to newline characters \n, and the input encoding will be guessed by analyzing the first bytes.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • NewlineInput

      public NewlineInput(InputStream is) throws IOException
      Constructor.
      Parameters:
      is - input stream
      Throws:
      IOException - I/O exception
    • NewlineInput

      public NewlineInput(IO in) throws IOException
      Constructor.
      Parameters:
      in - input
      Throws:
      IOException - I/O exception
    • NewlineInput

      public NewlineInput(byte[] token) throws IOException
      Constructor.
      Parameters:
      token - token
      Throws:
      IOException - I/O exception
  • Method Details

    • encoding

      public NewlineInput encoding(String encoding) throws IOException
      Description copied from class: TextInput
      Sets a new encoding.
      Overrides:
      encoding in class TextInput
      Parameters:
      encoding - encoding (ignored if null or an empty string)
      Returns:
      self reference
      Throws:
      IOException - I/O Exception
    • read

      public int read() throws IOException
      Description copied from class: TextInput
      Returns the next codepoint.
      Overrides:
      read in class TextInput
      Returns:
      next codepoint
      Throws:
      IOException - I/O exception
    • readLine

      public String readLine() throws IOException
      Reads and returns a single line.
      Returns:
      line or null
      Throws:
      IOException - I/O exception
    • readLine

      public boolean readLine(TokenBuilder tb) throws IOException
      Copies a single line to the specified token builder.
      Parameters:
      tb - token builder to be filled
      Returns:
      true if more input was found
      Throws:
      IOException - I/O exception