- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- de.carne.io.ChecksumOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ChecksumOutputStream extends java.io.FilterOutputStreamFilterOutputStream that calculates a checksum of the written data.
-
-
Constructor Summary
Constructors Constructor Description ChecksumOutputStream(java.io.OutputStream out, Checksum checksum)Constructs a new ChecksumOutputStream instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getChecksumValue()Gets the checksum value corresponding to the written data and resets the checksum processor.voidwrite(byte @Nullable [] b)voidwrite(byte @Nullable [] b, int off, int len)voidwrite(int b)
-
-
-
Constructor Detail
-
ChecksumOutputStream
public ChecksumOutputStream(java.io.OutputStream out, Checksum checksum)Constructs a new ChecksumOutputStream instance.- Parameters:
out- the underlying OutputStream.checksum- the Checksum instance to use for checksum calculation.
-
-
Method Detail
-
getChecksumValue
public byte[] getChecksumValue()
Gets the checksum value corresponding to the written data and resets the checksum processor.- Returns:
- the checksum value corresponding to the written data.
- See Also:
Checksum.getValue()
-
write
public void write(int b) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(byte @Nullable [] b) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
write
public void write(byte @Nullable [] b, int off, int len) throws java.io.IOException- Overrides:
writein classjava.io.FilterOutputStream- Throws:
java.io.IOException
-
-