CheckedOutputStreampublic class CheckedOutputStream extends FilterOutputStream The {@code CheckedOutputStream} class is used to maintain a running checksum
of all data written to a stream. The purpose of this checksum is to establish
data integrity, by publishing the checksum to other parties wanting to read
the non corrupted data. |
Fields Summary |
---|
private final Checksum | check |
Constructors Summary |
---|
public CheckedOutputStream(OutputStream os, Checksum cs)Constructs a new {@code CheckedOutputStream} on {@code OutputStream}
{@code os}. The checksum is calculated using the algorithm implemented
by {@code csum}.
super(os);
check = cs;
|
Methods Summary |
---|
public java.util.zip.Checksum | getChecksum()Returns the checksum calculated on the stream read so far.
return check;
| public void | write(int val)Writes the specified byte to the underlying stream. The checksum is
updated with {@code val}.
out.write(val);
check.update(val);
| public void | write(byte[] buf, int off, int nbytes)Writes n bytes of data from {@code buf} starting at offset {@code off} to
the underlying stream. The checksum is updated with the bytes written.
out.write(buf, off, nbytes);
check.update(buf, off, nbytes);
|
|