Class CheckedOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

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

      Fields 
      Modifier and Type Field Description
      private Checksum sum
      The checksum object.
      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      CheckedOutputStream​(java.io.OutputStream out, Checksum cksum)
      Creates a new CheckInputStream on top of the supplied OutputStream using the supplied Checksum.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Checksum getChecksum()
      Returns the Checksum object used.
      void write​(byte[] buf, int off, int len)
      Writes the byte array to the OutputStream and updates the Checksum.
      void write​(int bval)
      Writes one byte to the OutputStream and updates the Checksum.
      • Methods inherited from class java.io.FilterOutputStream

        close, flush, write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • sum

        private final Checksum sum
        The checksum object.
    • Constructor Detail

      • CheckedOutputStream

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

      • 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 java.io.IOException
        Writes one byte to the OutputStream and updates the Checksum.
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

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