Class CountingOutputStream

  • All Implemented Interfaces:
    , ,

    @GwtIncompatible
    public final class CountingOutputStream
    extends 
    An OutputStream that counts the number of bytes written.
    Since:
    1.0
    Author:
    Chris Nokleberg
    • Field Summary

      • Fields inherited from class java.io.

    • Constructor Summary

      Constructors 
      Constructor Description
       out)
      Wraps another output stream, counting the number of bytes written.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes this output stream and releases any system resources associated with the stream.
      long getCount()
      Returns the number of bytes written.
      void write​(byte[] b, int off, int len)
      Writes len bytes from the specified byte array starting at offset off to this output stream.
      void write​(int b)
      Writes the specified byte to this output stream.
      • Methods inherited from class java.io.

        ,
      • Methods inherited from class java.io.

      • Methods inherited from class java.lang.

        , , , , , , , , , ,
    • Constructor Detail

      • CountingOutputStream

        public  out)
        Wraps another output stream, counting the number of bytes written.
        Parameters:
        out - the output stream to be wrapped
    • Method Detail

      • getCount

        public long getCount()
        Returns the number of bytes written.
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws 
        Description copied from class: 
        Writes len bytes from the specified byte array starting at offset off to this output stream.

        The write method of FilterOutputStream calls the write method of one argument on each byte to output.

        Note that this method does not call the write method of its underlying output stream with the same arguments. Subclasses of FilterOutputStream should provide a more efficient implementation of this method.

        Overrides:
         in class 
        Parameters:
        b - the data.
        off - the start offset in the data.
        len - the number of bytes to write.
        Throws:
        - if an I/O error occurs.
        See Also:
      • write

        public void write​(int b)
                   throws 
        Description copied from class: 
        Writes the specified byte to this output stream.

        The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).

        Implements the abstract write method of OutputStream.

        Overrides:
         in class 
        Parameters:
        b - the byte.
        Throws:
        - if an I/O error occurs.
      • close

        public void close()
                   throws 
        Description copied from class: 
        Closes this output stream and releases any system resources associated with the stream.

        When not already closed, the close method of FilterOutputStream calls its flush method, and then calls the close method of its underlying output stream.

        Specified by:
         in interface 
        Specified by:
         in interface 
        Overrides:
         in class 
        Throws:
        - if an I/O error occurs.
        See Also:
        ,