- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.util.zip.CheckedInputStream
-
- All Implemented Interfaces:
- Closeable, AutoCloseable
public class CheckedInputStream extends FilterInputStream
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.- See Also:
Checksum
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor and Description CheckedInputStream(InputStream in, Checksum cksum)
Creates an input stream using the specified Checksum.
-
Method Summary
Methods Modifier and Type Method and Description Checksum
getChecksum()
Returns the Checksum for this input stream.int
read()
Reads a byte.int
read(byte[] buf, int off, int len)
Reads into an array of bytes.long
skip(long n)
Skips specified number of bytes of input.
-
-
-
Constructor Detail
-
CheckedInputStream
public CheckedInputStream(InputStream in, Checksum cksum)
Creates an input stream using the specified Checksum.- Parameters:
in
- the input streamcksum
- the Checksum
-
-
Method Detail
-
read
public int read() throws IOException
Reads a byte. Will block if no input is available.- Overrides:
read
in 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:
FilterInputStream.in
-
read
public int read(byte[] buf, int off, int len) throws IOException
Reads into an array of bytes. Iflen
is not zero, the method blocks until some input is available; otherwise, no bytes are read and0
is returned.- Overrides:
read
in classFilterInputStream
- Parameters:
buf
- the buffer into which the data is readoff
- the start offset in the destination arrayb
len
- 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
- Ifbuf
isnull
.IndexOutOfBoundsException
- Ifoff
is negative,len
is negative, orlen
is greater thanbuf.length - off
IOException
- if an I/O error has occurred- See Also:
FilterInputStream.in
-
skip
public long skip(long n) throws IOException
Skips specified number of bytes of input.- Overrides:
skip
in 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
-
getChecksum
public Checksum getChecksum()
Returns the Checksum for this input stream.- Returns:
- the Checksum value
-
-
Document created the 11/06/2005, last modified the 04/03/2020
Source of the printed document:https://www.gaudry.be/en/java-api-rf-java/util/zip/checkedinputstream.html
The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.
References
These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.