Class CountingInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
com.adobe.internal.io.CountingInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
RangedInputStream

public class CountingInputStream extends FilterInputStream
A FilterInputStream wrapper that counts the number of bytes read from the stream or skipped over since the creation of this wrapper.
  • Constructor Details

    • CountingInputStream

      public CountingInputStream(InputStream is)
      Parameters:
      is -
  • Method Details

    • read

      public int read() throws IOException
      Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
      Overrides:
      read in class FilterInputStream
      Returns:
      the next byte of data or -1 if the end of stream is reached
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(byte[] b, int off, int len) throws IOException
      Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available.
      Overrides:
      read in class FilterInputStream
      Parameters:
      b - the buffer into which the data is read
      off - the start offset in the buffer to write the data
      len - the maximum number of bytes to read
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
      Throws:
      IOException - if an I/O error occurs
    • read

      public int read(byte[] b) throws IOException
      Reads up to byte.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.
      Overrides:
      read in class FilterInputStream
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
      Throws:
      IOException - if an I/O error occurs
    • skip

      public long skip(long n) throws IOException
      Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.
      Overrides:
      skip in class FilterInputStream
      Parameters:
      n - the number of bytes to be skipped
      Returns:
      the actual number of bytes skipped
      Throws:
      IOException - if an I/O error occurs
    • getOffset

      public long getOffset()
      Get the offset in the wrapped stream since the creation of this wrapper.
      Returns:
      the offset in bytes