java.util.zip
Class CheckedOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
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
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.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CheckedOutputStream
public CheckedOutputStream(OutputStream out,
Checksum cksum)
- Creates a new CheckInputStream on top of the supplied OutputStream
using the supplied Checksum.
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 fromoff
- The index into the array to start writing bytes fromlen
- The number of bytes to write
- Throws:
IOException
- If an error occurs