Android
java.util.zip
public class

java.util.zip.CheckedInputStream

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

The CheckedInputStream class is used to maintain a running Checksum of all data read from a stream.

Summary

Fields inherited from class java.io.FilterInputStream

Public Constructors

            CheckedInputStream(InputStream is, Checksum csum)
Constructs a new CheckedInputStream on InputStream is.

Public Methods

          Checksum  getChecksum()
Returns the Checksum calculated on the stream thus far.
          int  read(byte[] buf, int off, int nbytes)
Reads up to nbytes of data from the underlying stream, storing it in buf, starting at offset off.
          int  read()
Reads a byte of data from the underlying stream and recomputes the Checksum with the byte data.
          long  skip(long nbytes)
Skip upto nbytes of data on the underlying stream.
Methods inherited from class java.io.FilterInputStream
Methods inherited from class java.io.InputStream
Methods inherited from class java.lang.Object
Methods inherited from interface java.io.Closeable

Details

Public Constructors

public CheckedInputStream(InputStream is, Checksum csum)

Constructs a new CheckedInputStream on InputStream is. The Checksum will be calculated using the algorithm implemented by csum.

Parameters

is InputStream to calculate checksum from
csum Type of Checksum to calculate

Public Methods

public Checksum getChecksum()

Returns the Checksum calculated on the stream thus far.

Returns

  • A java.util.zip.Checksum

public int read(byte[] buf, int off, int nbytes)

Reads up to nbytes of data from the underlying stream, storing it in buf, starting at offset off. The Checksum is updated with the bytes read.

Parameters

buf the byte array in which to store the read bytes.
off the offset in buffer to store the read bytes.
nbytes the maximum number of bytes to store in buffer.

Returns

  • Number of bytes read, -1 if end of stream

Throws

IOException

public int read()

Reads a byte of data from the underlying stream and recomputes the Checksum with the byte data.

Returns

  • -1 if end of stream, a single byte value otherwise

Throws

IOException

public long skip(long nbytes)

Skip upto nbytes of data on the underlying stream. Any skipped bytes are added to the running Checksum value.

Parameters

nbytes long Number of bytes to skip

Returns

  • Number of bytes skipped

Throws

IOException
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:48