net.sf.jazzlib
Class CheckedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java13.io.FilterOutputStream
          extended by net.sf.jazzlib.CheckedOutputStream

public class CheckedOutputStream
extends FilterOutputStream

OutputStream that computes a checksum of data being written using a supplied Checksum object.

Author:
Tom Tromey
See Also:
Checksum

Field Summary
 
Fields inherited from class java13.io.FilterOutputStream
out
 
Constructor Summary
CheckedOutputStream(java.io.OutputStream out, Checksum cksum)
          Creates a new CheckInputStream on top of the supplied OutputStream using the supplied Checksum.
 
Method Summary
 Checksum getChecksum()
          Returns the Checksum object used.
 void write(byte[] buf, int off, int len)
          Writes the byte array to the OutputStream and updates the Checksum.
 void write(int bval)
          Writes one byte to the OutputStream and updates the Checksum.
 
Methods inherited from class java13.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckedOutputStream

public CheckedOutputStream(java.io.OutputStream out,
                           Checksum cksum)
Creates a new CheckInputStream on top of the supplied OutputStream using the supplied Checksum.

Method Detail

getChecksum

public Checksum getChecksum()
Returns the Checksum object used. To get the data checksum computed so far call getChecksum.getValue().


write

public void write(int bval)
           throws java.io.IOException
Writes one byte to the OutputStream and updates the Checksum.

Overrides:
write in class FilterOutputStream
Parameters:
bval - the byte.
Throws:
java.io.IOException - if an I/O error occurs.

write

public void write(byte[] buf,
                  int off,
                  int len)
           throws java.io.IOException
Writes the byte array to the OutputStream and updates the Checksum.

Overrides:
write in class FilterOutputStream
Parameters:
buf - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
java.io.IOException - if an I/O error occurs.
See Also:
java.io.FilterOutputStream#write(int)