CheckedInputStream (Java Platform SE 7 ) (original) (raw)
- java.io.InputStream
- java.io.FilterInputStream
- java.util.zip.CheckedInputStream
- java.io.FilterInputStream
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](../../../java/io/FilterInputStream.html "class in java.io") `[in](../../../java/io/FilterInputStream.html#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. * ### Methods inherited from class java.io.[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io") `[available](../../../java/io/FilterInputStream.html#available%28%29), [close](../../../java/io/FilterInputStream.html#close%28%29), [mark](../../../java/io/FilterInputStream.html#mark%28int%29), [markSupported](../../../java/io/FilterInputStream.html#markSupported%28%29), [read](../../../java/io/FilterInputStream.html#read%28byte[]%29), [reset](../../../java/io/FilterInputStream.html#reset%28%29)` * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[clone](../../../java/lang/Object.html#clone%28%29), [equals](../../../java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java/lang/Object.html#finalize%28%29), [getClass](../../../java/lang/Object.html#getClass%28%29), [hashCode](../../../java/lang/Object.html#hashCode%28%29), [notify](../../../java/lang/Object.html#notify%28%29), [notifyAll](../../../java/lang/Object.html#notifyAll%28%29), [toString](../../../java/lang/Object.html#toString%28%29), [wait](../../../java/lang/Object.html#wait%28%29), [wait](../../../java/lang/Object.html#wait%28long%29), [wait](../../../java/lang/Object.html#wait%28long,%20int%29)`Constructor Detail
* #### CheckedInputStream public CheckedInputStream([InputStream](../../../java/io/InputStream.html "class in java.io") in, [Checksum](../../../java/util/zip/Checksum.html "interface in java.util.zip") cksum) Creates an input stream using the specified Checksum. Parameters: `in` \- the input stream `cksum` \- the ChecksumMethod Detail
* #### read public int read() throws [IOException](../../../java/io/IOException.html "class in java.io") Reads a byte. Will block if no input is available. **Overrides:** `[read](../../../java/io/FilterInputStream.html#read%28%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Returns: the byte read, or -1 if the end of the stream is reached. Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error has occurred See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in) * #### read public int read(byte[] buf, int off, int len) throws [IOException](../../../java/io/IOException.html "class in java.io") Reads into an array of bytes. If `len` is not zero, the method blocks until some input is available; otherwise, no bytes are read and `0` is returned. **Overrides:** `[read](../../../java/io/FilterInputStream.html#read%28byte[],%20int,%20int%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Parameters: `buf` \- the buffer into which the data is read `off` \- the start offset in the destination array `b` `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](../../../java/lang/NullPointerException.html "class in java.lang")` \- If `buf` is `null`. `[IndexOutOfBoundsException](../../../java/lang/IndexOutOfBoundsException.html "class in java.lang")` \- If `off` is negative,`len` is negative, or `len` is greater than`buf.length - off` `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error has occurred See Also: [FilterInputStream.in](../../../java/io/FilterInputStream.html#in) * #### skip public long skip(long n) throws [IOException](../../../java/io/IOException.html "class in java.io") Skips specified number of bytes of input. **Overrides:** `[skip](../../../java/io/FilterInputStream.html#skip%28long%29)` in class `[FilterInputStream](../../../java/io/FilterInputStream.html "class in java.io")` Parameters: `n` \- the number of bytes to skip Returns: the actual number of bytes skipped Throws: `[IOException](../../../java/io/IOException.html "class in java.io")` \- if an I/O error has occurred * #### getChecksum public [Checksum](../../../java/util/zip/Checksum.html "interface in java.util.zip") getChecksum() Returns the Checksum for this input stream. Returns: the Checksum value
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.