Skip to content

Most visited

Recently visited

navigation
Added in API level 1

CheckedOutputStream

public class CheckedOutputStream
extends FilterOutputStream

java.lang.Object
   ↳ java.io.OutputStream
     ↳ java.io.FilterOutputStream
       ↳ java.util.zip.CheckedOutputStream


The CheckedOutputStream class is used to maintain a running checksum of all data written to a stream. The purpose of this checksum is to establish data integrity, by publishing the checksum to other parties wanting to read the non corrupted data.

Summary

Inherited fields

From class java.io.FilterOutputStream

Public constructors

CheckedOutputStream(OutputStream os, Checksum cs)

Constructs a new CheckedOutputStream on OutputStream os.

Public methods

Checksum getChecksum()

Returns the checksum calculated on the stream read so far.

void write(byte[] buf, int off, int nbytes)

Writes n bytes of data from buf starting at offset off to the underlying stream.

void write(int val)

Writes the specified byte to the underlying stream.

Inherited methods

From class java.io.FilterOutputStream
From class java.io.OutputStream
From class java.lang.Object
From interface java.io.Closeable
From interface java.io.Flushable
From interface java.lang.AutoCloseable

Public constructors

CheckedOutputStream

Added in API level 1
CheckedOutputStream (OutputStream os, 
                Checksum cs)

Constructs a new CheckedOutputStream on OutputStream os. The checksum is calculated using the algorithm implemented by csum.

Parameters
os OutputStream: the output stream to calculate checksum for.
cs Checksum: an entity implementing the checksum algorithm.

Public methods

getChecksum

Added in API level 1
Checksum getChecksum ()

Returns the checksum calculated on the stream read so far.

Returns
Checksum the updated checksum.

write

Added in API level 1
void write (byte[] buf, 
                int off, 
                int nbytes)

Writes n bytes of data from buf starting at offset off to the underlying stream. The checksum is updated with the bytes written.

Parameters
buf byte: data written to the output stream.
off int: the offset to start reading the data from buf written to the output stream.
nbytes int: number of bytes to write to the output stream.
Throws
IOException if an IO error has occurred.

write

Added in API level 1
void write (int val)

Writes the specified byte to the underlying stream. The checksum is updated with val.

Parameters
val int: the data value to written to the output stream.
Throws
IOException if an IO error has occurred.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

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.