org.jaudiotagger.audio.asf.io
Class CountingOutputstream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.jaudiotagger.audio.asf.io.CountingOutputstream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class CountingOutputstream
extends java.io.OutputStream

This output stream wraps around another OutputStream and delegates the write calls.
Additionally all written bytes are counted and available by getCount().

Author:
Christian Laireiter

Field Summary
private  long count
          Stores the amount of bytes written.
private  java.io.OutputStream wrapped
          The stream to forward the write calls.
 
Constructor Summary
CountingOutputstream(java.io.OutputStream outputStream)
          Creates an instance which will delegate the write calls to the given output stream.
 
Method Summary
 void close()
          
 void flush()
          
 long getCount()
           
 void write(byte[] bytes)
          
 void write(byte[] bytes, int off, int len)
          
 void write(int toWrite)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

private long count
Stores the amount of bytes written.


wrapped

private final java.io.OutputStream wrapped
The stream to forward the write calls.

Constructor Detail

CountingOutputstream

public CountingOutputstream(java.io.OutputStream outputStream)
Creates an instance which will delegate the write calls to the given output stream.

Parameters:
outputStream - stream to wrap.
Method Detail

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException

Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

getCount

public long getCount()
Returns:
the count

write

public void write(byte[] bytes)
           throws java.io.IOException

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] bytes,
                  int off,
                  int len)
           throws java.io.IOException

Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int toWrite)
           throws java.io.IOException

Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException