to top
Android APIs
public class

CheckedOutputStream

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

Class Overview

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

[Expand]
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.
[Expand]
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

public CheckedOutputStream (OutputStream os, Checksum cs)

Added in API level 1

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

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

Public Methods

public Checksum getChecksum ()

Added in API level 1

Returns the checksum calculated on the stream read so far.

Returns
  • the updated checksum.

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

Added in API level 1

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 data written to the output stream.
off the offset to start reading the data from buf written to the output stream.
nbytes number of bytes to write to the output stream.
Throws
IOException if an IO error has occurred.

public void write (int val)

Added in API level 1

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

Parameters
val the data value to written to the output stream.
Throws
IOException if an IO error has occurred.