Class TextInput

All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
NewlineInput

public class TextInput extends BufferInput
This class provides buffered access to textual input. The input encoding will initially be guessed by analyzing the first bytes; it can also be explicitly set by calling encoding(). UTF-8 will be used as default encoding.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • TextInput

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

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

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

    • encoding

      public final String encoding()
      Returns the encoding.
      Returns:
      encoding
    • validate

      public final TextInput validate(boolean flag)
      Checks the input for valid XML characters and throws an exception if invalid characters are found.
      Parameters:
      flag - flag to be set
      Returns:
      self reference
    • encoding

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

      public int read() throws IOException
      Returns the next codepoint.
      Overrides:
      read in class BufferInput
      Returns:
      next codepoint
      Throws:
      IOException - I/O exception
    • content

      public final byte[] content() throws IOException
      Description copied from class: BufferInput
      Retrieves and returns the whole data and closes the stream.
      Overrides:
      content in class BufferInput
      Returns:
      contents
      Throws:
      IOException - I/O exception
    • cache

      public final TokenBuilder cache() throws IOException
      Retrieves the whole text and closes the stream.
      Returns:
      token builder instance
      Throws:
      IOException - I/O exception