Class Overview
The 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.
Summary
Public Methods |
Checksum
|
getChecksum()
Returns the checksum calculated on the stream read so far.
|
void
|
write(int val)
Writes the specified byte to the underlying stream.
|
void
|
write(byte[] buf, int off, int nbytes)
Writes n bytes of data from buf starting at offset off to
the underlying stream.
|
[Expand]
Inherited Methods |
From class java.io.FilterOutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Ensures that all pending data is sent out to the target stream.
|
void
|
write(byte[] buffer)
Writes the entire contents of the byte array buffer to this
stream.
|
void
|
write(int oneByte)
Writes one byte to the target stream.
|
void
|
write(byte[] buffer, int offset, int length)
Writes count bytes from the byte array buffer starting at
offset to the target stream.
|
|
From class java.io.OutputStream
void
|
close()
Closes this stream.
|
void
|
flush()
Flushes this stream.
|
void
|
write(byte[] buffer)
Writes the entire contents of the byte array buffer to this
stream.
|
abstract
void
|
write(int oneByte)
Writes a single byte to this stream.
|
void
|
write(byte[] buffer, int offset, int count)
Writes count bytes from the byte array buffer starting at
position offset to this stream.
|
|
From class java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Is called before the object's memory is being reclaimed by the VM.
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of Class which represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
|
From interface java.io.Closeable
abstract
void
|
close()
Closes the object and release any system resources it holds.
|
|
From interface java.io.Flushable
abstract
void
|
flush()
Flushes the object by writing out any buffered data to the underlying
output.
|
|
Public Constructors
Constructs a new CheckedOutputStream
on OutputStream
os
. The checksum is calculated using the algorithm implemented
by csum
.
Parameters
os
| the output stream to calculate checksum for. |
cs
| an entity implementing the checksum algorithm.
|
Public Methods
public
Checksum
getChecksum
()
Returns the checksum calculated on the stream read so far.
public
void
write
(int val)
Writes the specified byte to the underlying stream. The checksum is
updated with val
.
Parameters
val
| the data value to written to the output stream. |
public
void
write
(byte[] buf, int off, int nbytes)
Writes n bytes of data from buf
starting at offset off
to
the underlying stream. The checksum is updated with the bytes written.
Parameters
buf
| data written to the output stream. |
off
| the offset to start reading the data from buf written
to the output stream. |
nbytes
| number of bytes to write to the output stream. |