Skip to content

Most visited

Recently visited

navigation

CheckedInputStream

public class CheckedInputStream
extends FilterInputStream

java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FilterInputStream
       ↳ java.util.zip.CheckedInputStream


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:

Summary

Inherited fields

From class java.io.FilterInputStream

Public constructors

CheckedInputStream(InputStream in, Checksum cksum)

Creates an input stream using the specified Checksum.

Public methods

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.

Inherited methods

From class java.io.FilterInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.lang.AutoCloseable

Public constructors

CheckedInputStream

added in API level 1
CheckedInputStream (InputStream in, 
                Checksum cksum)

Creates an input stream using the specified Checksum.

Parameters
in InputStream: the input stream

cksum Checksum: the Checksum

Public methods

getChecksum

added in API level 1
Checksum getChecksum ()

Returns the Checksum for this input stream.

Returns
Checksum the Checksum value

read

added in API level 1
int 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.

Throws
IOException if an I/O error has occurred

read

added in API level 1
int read (byte[] buf, 
                int off, 
                int len)

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.

Throws
NullPointerException If buf is null.
IndexOutOfBoundsException If off is negative, len is negative, or len is greater than buf.length - off
IOException if an I/O error has occurred

skip

added in API level 1
long skip (long n)

Skips specified number of bytes of input.

Parameters
n long: the number of bytes to skip

Returns
long the actual number of bytes skipped

Throws
IOException if an I/O error has occurred
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)