Class MonitorInputStream

All Implemented Interfaces:
Closeable, AutoCloseable

An InputStream that provides buffering and end-of-stream monitoring.
  • Constructor Details

    • MonitorInputStream

      Constructs a MonitorInputStream from the passed InputStream.
      Parameters:
      in - The input stream to wrap.
    • MonitorInputStream

      public MonitorInputStream(InputStream in, int bufferSize)
      Constructs a MonitorInputStream from the passed InputStream and with the specified buffer size.
      Parameters:
      in - The input stream to wrap.
      bufferSize - The buffer size to use.
      Since:
      2.4
  • Method Details

    • available

      public int available() throws IOException
      Returns 0 if the stream is at EOF, else the underlying inputStream will be queried.
      Overrides:
      available in class BufferedInputStream
      Returns:
      The number of bytes that are available.
      Throws:
      IOException - if an error occurs.
      Since:
      2.0
    • close

      public void close() throws IOException
      Closes this input stream and releases any system resources associated with the stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class BufferedInputStream
      Throws:
      IOException - if an error occurs.
    • closeSuper

      protected void closeSuper() throws IOException
      This method exists in order to allow overriding whether to actually close the underlying stream (VFS-805). There are cases where closing that stream will consume any amount of remaining data. In such cases closing a different entity instead (such as an HttpResponse) may be more appropriate.
      Throws:
      IOException - if an IO error occurs.
    • getCount

      public long getCount()
      Gets the number of bytes read by this input stream.
      Returns:
      The number of bytes read by this input stream.
    • onClose

      protected void onClose() throws IOException
      Called after the stream has been closed. This implementation does nothing.
      Throws:
      IOException - if an error occurs.
    • read

      public int read() throws IOException
      Reads a character.
      Overrides:
      read in class BufferedInputStream
      Returns:
      The character that was read as an integer.
      Throws:
      IOException - if an IO error occurs.
    • read

      public int read(byte[] buffer, int offset, int length) throws IOException
      Reads bytes from this input stream.
      Overrides:
      read in class BufferedInputStream
      Parameters:
      buffer - A byte array in which to place the characters read.
      offset - The offset at which to start reading.
      length - The maximum number of bytes to read.
      Returns:
      The number of bytes read.
      Throws:
      IOException - if an IO error occurs.