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()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
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
-