Class ChecksumCalculatingInputStream

    • Constructor Detail

      • ChecksumCalculatingInputStream

        public ChecksumCalculatingInputStream​(InputStream in,
                                              SdkChecksum cksum)
        Creates an input stream using the specified Checksum.
        Parameters:
        in - the input stream to read
        cksum - the Checksum implementation to use for computing the checksum
    • Method Detail

      • read

        public int read()
                 throws IOException
        Reads from the underlying stream. If the end of the stream is reached, the running checksum will be appended a byte at a time (1 per read call).
        Overrides:
        read in class FilterInputStream
        Returns:
        byte read, if eos has been reached, -1 will be returned.
        Throws:
        IOException
      • read

        public int read​(byte[] buf,
                        int off,
                        int len)
                 throws IOException
        Reads up to len bytes at a time from the input stream, updates the checksum. If the end of the stream has been reached the checksum will be appended to the last 4 bytes.
        Overrides:
        read in class FilterInputStream
        Parameters:
        buf - buffer to write into
        off - offset in the buffer to write to
        len - maximum number of bytes to attempt to read.
        Returns:
        number of bytes written into buf, otherwise -1 will be returned to indicate eos.
        Throws:
        IOException
      • getChecksumBytes

        public byte[] getChecksumBytes()