FileDocCategorySizeDatePackage
CountingOutputstream.javaAPI DocJaudiotagger 2.0.41995Wed Mar 30 16:11:50 BST 2011org.jaudiotagger.audio.asf.io

CountingOutputstream

public class CountingOutputstream extends OutputStream
This output stream wraps around another {@link OutputStream} and delegates the write calls.
Additionally all written bytes are counted and available by {@link #getCount()}.
author
Christian Laireiter

Fields Summary
private long
count
Stores the amount of bytes written.
private final OutputStream
wrapped
The stream to forward the write calls.
Constructors Summary
public CountingOutputstream(OutputStream outputStream)
Creates an instance which will delegate the write calls to the given output stream.

param
outputStream stream to wrap.


                                        
        
        super();
        assert outputStream != null;
        this.wrapped = outputStream;
    
Methods Summary
public voidclose()
{@inheritDoc}

        this.wrapped.close();
    
public voidflush()
{@inheritDoc}

        this.wrapped.flush();
    
public longgetCount()

return
the count

        return this.count;
    
public voidwrite(byte[] bytes)
{@inheritDoc}

        this.wrapped.write(bytes);
        this.count += bytes.length;
    
public voidwrite(byte[] bytes, int off, int len)
{@inheritDoc}

        this.wrapped.write(bytes, off, len);
        this.count += len;
    
public voidwrite(int toWrite)
{@inheritDoc}

        this.wrapped.write(toWrite);
        this.count++;