java.util.zip
Class CheckedOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.util.zip.CheckedOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class CheckedOutputStream
extends FilterOutputStream

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

See Also:
Checksum

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
CheckedOutputStream(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 java.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CheckedOutputStream

public CheckedOutputStream(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 IOException
Writes one byte to the OutputStream and updates the Checksum.

Overrides:
write in class FilterOutputStream
Parameters:
bval - The byte to write, passed as an int.
Throws:
IOException - If an error occurs

write

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

Overrides:
write in class FilterOutputStream
Parameters:
buf - The byte array to write bytes from
off - The index into the array to start writing bytes from
len - The number of bytes to write
Throws:
IOException - If an error occurs