Package net.sf.jazzlib
Class CheckedOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- net.sf.jazzlib.CheckedOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class CheckedOutputStream extends java.io.FilterOutputStreamOutputStream that computes a checksum of data being written using a supplied Checksum object.- See Also:
Checksum
-
-
Constructor Summary
Constructors Constructor Description CheckedOutputStream(java.io.OutputStream out, Checksum cksum)Creates a new CheckInputStream on top of the supplied OutputStream using the supplied Checksum.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ChecksumgetChecksum()Returns the Checksum object used.voidwrite(byte[] buf, int off, int len)Writes the byte array to the OutputStream and updates the Checksum.voidwrite(int bval)Writes one byte to the OutputStream and updates the Checksum.
-
-
-
Field Detail
-
sum
private final Checksum sum
The checksum object.
-
-
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 callgetChecksum.getValue().
-
write
public void write(int bval) throws java.io.IOExceptionWrites one byte to the OutputStream and updates the Checksum.- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(byte[] buf, int off, int len) throws java.io.IOExceptionWrites the byte array to the OutputStream and updates the Checksum.- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
-