open class CheckedInputStream : 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.
Summary
Public constructors
|
|
Creates an input stream using the specified Checksum.
|
Public methods
|
| open Checksum! |
Returns the Checksum for this input stream.
|
| open Int |
Reads a byte.
|
| open Int |
Reads into an array of bytes.
|
| open Long |
Skips specified number of bytes of input.
|
Inherited functions
|
From class FilterInputStream
Int |
available()
Returns 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. The next caller might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.
This method returns the result of in.available().
|
Unit |
close()
Closes this input stream and releases any system resources associated with the stream. This method simply performs in.close().
|
Unit |
mark(readlimit: Int)
Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.
The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.
This method simply performs in.mark(readlimit).
|
Boolean |
markSupported()
Tests if this input stream supports the mark and reset methods. This method simply performs in.markSupported().
|
Int |
read(b: ByteArray!)
Reads up to byte.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.
This method simply performs the call read(b, 0, b.length) and returns the result. It is important that it does not do in.read(b) instead; certain subclasses of FilterInputStream depend on the implementation strategy actually used.
|
Unit |
reset()
Repositions this stream to the position at the time the mark method was last called on this input stream.
This method simply performs in.reset().
Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.
|
|
Public constructors
<init>
CheckedInputStream(
in: InputStream!,
cksum: Checksum!)
Creates an input stream using the specified Checksum.
Public methods
getChecksum
open fun getChecksum(): Checksum!
Returns the Checksum for this input stream.
read
open fun read(): Int
Reads a byte. Will block if no input is available.
| Return |
Int |
the byte read, or -1 if the end of the stream is reached. |
| Exceptions |
java.io.IOException |
if an I/O error has occurred |
read
open fun read(
buf: ByteArray!,
off: Int,
len: Int
): Int
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.
| Parameters |
b |
the buffer into which the data is read. |
off |
Int: the start offset in the destination array b |
len |
Int: the maximum number of bytes read |
buf |
ByteArray!: the buffer into which the data is read |
| Return |
Int |
the actual number of bytes read, or -1 if the end of the stream is reached. |
| Exceptions |
java.lang.NullPointerException |
If buf is null. |
java.lang.IndexOutOfBoundsException |
If off is negative, len is negative, or len is greater than buf.length - off |
java.io.IOException |
if an I/O error has occurred |
skip
open fun skip(n: Long): Long
Skips specified number of bytes of input.
| Parameters |
n |
Long: the number of bytes to skip |
| Return |
Long |
the actual number of bytes skipped |
| Exceptions |
java.io.IOException |
if an I/O error has occurred |