Class CheckedInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.util.zip.CheckedInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
An input stream that also maintains a checksum of the data being read.
The checksum can then be used to verify the integrity of the input data.
- Since:
- 1.1
- See Also:
-
Field Summary
Fields declared in class FilterInputStream
in -
Constructor Summary
ConstructorsConstructorDescriptionCheckedInputStream(InputStream in, Checksum cksum) Creates an input stream using the specified Checksum. -
Method Summary
Methods declared in class FilterInputStream
available, close, mark, markSupported, read, resetModifier and TypeMethodDescriptionintReturns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.voidclose()Closes this input stream and releases any system resources associated with the stream.voidmark(int readlimit) Marks the current position in this input stream.booleanTests if this input stream supports themarkandresetmethods.intread(byte[] b) Reads up tob.lengthbytes of data from this input stream into an array of bytes.voidreset()Repositions this stream to the position at the time themarkmethod was last called on this input stream.Methods declared in class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferToModifier and TypeMethodDescriptionstatic InputStreamReturns a newInputStreamthat reads no bytes.byte[]Reads all remaining bytes from the input stream.intreadNBytes(byte[] b, int off, int len) Reads the requested number of bytes from the input stream into the given byte array.byte[]readNBytes(int len) Reads up to a specified number of bytes from the input stream.voidskipNBytes(long n) Skips over and discards exactlynbytes of data from this input stream.longtransferTo(OutputStream out) Reads all bytes from this input stream and writes the bytes to the given output stream in the order that they are read.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
CheckedInputStream
Creates an input stream using the specified Checksum.- Parameters:
in- the input streamcksum- the Checksum
-
-
Method Details
-
read
Reads a byte. Will block if no input is available.- Overrides:
readin classFilterInputStream- Returns:
- the byte read, or -1 if the end of the stream is reached.
- Throws:
IOException- if an I/O error has occurred- See Also:
-
read
Reads into an array of bytes. Iflenis not zero, the method blocks until some input is available; otherwise, no bytes are read and0is returned.- Overrides:
readin classFilterInputStream- Parameters:
buf- the buffer into which the data is readoff- the start offset in the destination arrayblen- the maximum number of bytes read- Returns:
- the actual number of bytes read, or -1 if the end of the stream is reached.
- Throws:
NullPointerException- Ifbufisnull.IndexOutOfBoundsException- Ifoffis negative,lenis negative, orlenis greater thanbuf.length - offIOException- if an I/O error has occurred- See Also:
-
skip
Skips specified number of bytes of input.- Overrides:
skipin classFilterInputStream- Parameters:
n- the number of bytes to skip- Returns:
- the actual number of bytes skipped
- Throws:
IOException- if an I/O error has occurred- See Also:
-
getChecksum
Returns the Checksum for this input stream.- Returns:
- the Checksum value
-