Class CheckedOutputStream

All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class CheckedOutputStream extends FilterOutputStream
OutputStream that computes a checksum of data being written using a supplied Checksum object.
See Also:
  • Field Details

    • sum

      private final Checksum sum
      The checksum object.
  • Constructor Details

    • CheckedOutputStream

      public CheckedOutputStream(OutputStream out, Checksum cksum)
      Creates a new CheckInputStream on top of the supplied OutputStream using the supplied Checksum.
  • Method Details

    • getChecksum

      public Checksum getChecksum()
      Returns the Checksum object used. To get the data checksum computed so far call getChecksum.getValue().
    • write

      public void write(int bval) throws IOException
      Writes one byte to the OutputStream and updates the Checksum.
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException
    • write

      public void write(byte[] buf, int off, int len) throws IOException
      Writes the byte array to the OutputStream and updates the Checksum.
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException