Class BufferInput

java.lang.Object
java.io.InputStream
org.basex.io.in.BufferInput
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
ArrayInput, DataInput, TextInput

public class BufferInput extends InputStream
This class uses an internal buffer to speed up input stream processing.
Author:
BaseX Team 2005-21, BSD License, Christian Gruen
  • Constructor Details

    • BufferInput

      public BufferInput(IO input) throws IOException
      Constructor.
      Parameters:
      input - input to be read
      Throws:
      IOException - I/O Exception
    • BufferInput

      public BufferInput(InputStream is)
      Constructor.
      Parameters:
      is - input stream
    • BufferInput

      public BufferInput(InputStream in, int bufsize)
      Initializes the file reader.
      Parameters:
      in - input stream
      bufsize - buffer size
  • Method Details

    • get

      public static BufferInput get(InputStream in)
      Returns a buffered input stream.
      Parameters:
      in - input stream
      Returns:
      stream
    • get

      public static BufferInput get(IO input) throws IOException
      Returns a buffered input stream.
      Parameters:
      input - input to be read
      Returns:
      stream
      Throws:
      IOException - I/O Exception
    • io

      public final IO io()
      Returns the IO reference or null.
      Returns:
      file reference
    • read

      public int read() throws IOException
      Returns the next byte. By default, this method calls readByte(); -1 is returned if all bytes have been read.
      Specified by:
      read in class InputStream
      Returns:
      next byte
      Throws:
      IOException - I/O exception
    • readString

      public final String readString() throws IOException
      Reads a string from the input stream, suffixed by a 0 byte.
      Returns:
      string
      Throws:
      IOException - I/O Exception
    • readBytes

      public final byte[] readBytes() throws IOException
      Reads a byte array from the input stream, suffixed by a 0 byte.
      Returns:
      token
      Throws:
      IOException - I/O Exception
    • close

      public final void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException
    • size

      public final int size()
      Returns the number of read bytes.
      Returns:
      read bytes
    • length

      public final long length()
      Returns the input length (can be -1).
      Returns:
      input length
    • markSupported

      public final boolean markSupported()
      Overrides:
      markSupported in class InputStream
    • mark

      public final void mark(int m)
      Overrides:
      mark in class InputStream
    • reset

      public final void reset() throws IOException
      Overrides:
      reset in class InputStream
      Throws:
      IOException
    • content

      public byte[] content() throws IOException
      Retrieves and returns the whole data and closes the stream.
      Returns:
      contents
      Throws:
      IOException - I/O exception