Package net.sf.jazzlib
Class CheckedInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
net.sf.jazzlib.CheckedInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
InputStream that computes a checksum of the data being read using a supplied
Checksum object.
- See Also:
-
Field Summary
FieldsFields inherited from class java.io.FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionCheckedInputStream(InputStream in, Checksum sum) Creates a new CheckInputStream on top of the supplied OutputStream using the supplied Checksum. -
Method Summary
Modifier and TypeMethodDescriptionReturns the Checksum object used.intread()Reads one byte, updates the checksum and returns the read byte (or -1 when the end of file was reached).intread(byte[] buf, int off, int len) Reads at most len bytes in the supplied buffer and updates the checksum with it.longskip(long n) Skips n bytes by reading them in a temporary buffer and updating the the checksum with that buffer.Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, resetMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
sum
The checksum object.
-
-
Constructor Details
-
CheckedInputStream
Creates a new CheckInputStream on top of the supplied OutputStream using the supplied Checksum.
-
-
Method Details
-
getChecksum
Returns the Checksum object used. To get the data checksum computed so far callgetChecksum.getValue(). -
read
Reads one byte, updates the checksum and returns the read byte (or -1 when the end of file was reached).- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
Reads at most len bytes in the supplied buffer and updates the checksum with it. Returns the number of bytes actually read or -1 when the end of file was reached.- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
Skips n bytes by reading them in a temporary buffer and updating the the checksum with that buffer. Returns the actual number of bytes skiped which can be less then requested when the end of file is reached.- Overrides:
skipin classFilterInputStream- Throws:
IOException
-