Class MeasuredInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable
    Direct Known Subclasses:
    GuardedInputStream


    public class MeasuredInputStream
    extends InputStream
    This InputStream relays information from an underlying InputStream while measuring how many bytes have been read or skipped.

    Note marking is not supported in this object.

    • Constructor Detail

      • MeasuredInputStream

        public MeasuredInputStream(InputStream i)
    • Method Detail

      • setCloseable

        public void setCloseable(boolean b)
        Control whether calling close() affects the underlying InputStream. This is useful in cases when you pass an InputStream to a 3rd party decoder that helpfully tries to close the stream as it wraps up, but there is still data to be read later (such as when working with a ZipInputStream).
        Parameters:
        b - whether calling close() will close the underlying InputStream.
      • isCloseable

        public boolean isCloseable()
      • getReadBytes

        public long getReadBytes()
        Returns the number of bytes that have been read (or skipped).
        Returns:
        the number of bytes that have been read (or skipped).
      • mark

        public void mark(int readlimit)
      • markSupported

        public boolean markSupported()
      • seek

        public void seek(long pos)
                  throws IOException
        This skips forward to the requested position. If the requested position is less than the current position, then an exception is thrown.
        Parameters:
        pos -
        Throws:
        IOException -