Package 

Class CountingInputStream

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public class CountingInputStream
    extends InputStream
                        

    An input stream that counts the bytes read from it.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int counter
    • Constructor Summary

      Constructors 
      Constructor Description
      CountingInputStream(InputStream in) Constructs a new CountingInputStream wrapping the supplied input stream.
    • Method Summary

      Modifier and Type Method Description
      int getCounter() Returns the number of bytes read since the last reset.
      int read()
      void resetCounter() Resets the counter to zero.
      • Methods inherited from class java.io.InputStream

        available, close, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CountingInputStream

        CountingInputStream(InputStream in)
        Constructs a new CountingInputStream wrapping the supplied input stream.
    • Method Detail

      • getCounter

         int getCounter()

        Returns the number of bytes read since the last reset.

      • resetCounter

         void resetCounter()

        Resets the counter to zero.