APIdia Launch Partner
Top Description Fields Constructors Methods
java.util.zip

public Class CheckedInputStream

extends FilterInputStream
Class Inheritance
Imports
java.io.FilterInputStream, .InputStream, .IOException

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.
Author
David Connelly
Since
1.1
See Also
Checksum

Field Summary

Modifier and TypeField and Description
private Checksum
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public
CheckedInputStream(InputStream
the input stream
in
,
Checksum
the Checksum
cksum
)

Creates an input stream using the specified Checksum.

Method Summary

Modifier and TypeMethod and Description
public Checksum

Returns:

the Checksum value
getChecksum
()

Returns the Checksum for this input stream.

public int

Returns:

the byte read, or -1 if the end of the stream is reached.
read
()

Overrides java.io.FilterInputStream.read.

Reads a byte.

public int

Returns:

the actual number of bytes read, or -1 if the end of the stream is reached.
read
(byte[]
the buffer into which the data is read
buf
,
int
the start offset in the destination array b
off
,
int
the maximum number of bytes read
len
)

Overrides java.io.FilterInputStream.read.

Reads into an array of bytes.

public long

Returns:

the actual number of bytes skipped
skip
(long
the number of bytes to skip
n
)

Overrides java.io.FilterInputStream.skip.

Skips specified number of bytes of input.

Inherited from java.io.FilterInputStream:
availableclosemarkmarkSupportedreadreset

Field Detail

cksumback to summary
private Checksum cksum

Constructor Detail

CheckedInputStreamback to summary
public CheckedInputStream(InputStream in, Checksum cksum)

Creates an input stream using the specified Checksum.

Parameters
in:InputStream

the input stream

cksum:Checksum

the Checksum

Method Detail

getChecksumback to summary
public Checksum getChecksum()

Returns the Checksum for this input stream.

Returns:Checksum

the Checksum value

readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Reads a byte. Will block if no input is available.

Returns:int

the byte read, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error has occurred
readback to summary
public int read(byte[] buf, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

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
buf:byte[]

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

Returns:int

the actual number of bytes read, or -1 if the end of the stream is reached.

Exceptions
IOException:
if an I/O error has occurred
NullPointerException:
If buf is null.
IndexOutOfBoundsException:
If off is negative, len is negative, or len is greater than buf.length - off
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Skips specified number of bytes of input.

Parameters
n:long

the number of bytes to skip

Returns:long

the actual number of bytes skipped

Exceptions
IOException:
if an I/O error has occurred