CheckedInputStream (Java 2 Platform SE 5.0) (original) (raw)


java.util.zip

Class CheckedInputStream

java.lang.Object extended by java.io.InputStream extended by java.io.FilterInputStream extended by java.util.zip.CheckedInputStream

All Implemented Interfaces:

Closeable


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
[CheckedInputStream](../../../java/util/zip/CheckedInputStream.html#CheckedInputStream%28java.io.InputStream, java.util.zip.Checksum%29)(InputStream in,Checksum cksum) Creates an input stream using the specified Checksum.
Method Summary
Checksum getChecksum() Returns the Checksum for this input stream.
int read() Reads a byte.
int [read](../../../java/util/zip/CheckedInputStream.html#read%28byte[], int, int%29)(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
available, close, mark, markSupported, read, reset
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../../java/lang/Object.html#wait%28long, int%29)
Constructor Detail

CheckedInputStream

public CheckedInputStream(InputStream in, Checksum cksum)

Creates an input stream using the specified Checksum.

Parameters:

in - the input stream

cksum - the Checksum

Method Detail

read

public int read() throws IOException

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


read

public int read(byte[] buf, int off, int len) throws IOException

Reads into an array of bytes. Will block until some input is available.

Overrides:

[read](../../../java/io/FilterInputStream.html#read%28byte[], int, int%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 of the data

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:

[IOException](../../../java/io/IOException.html "class in java.io") - 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](../../../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 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 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.