Class HashingInputStream

    • Method Summary

      Modifier and Type Method and Description
      HashCode hash()
      Returns the HashCode based on the data read from this stream.
      void mark(int readlimit)
      mark() is not supported for HashingInputStream
      boolean markSupported()
      mark() is not supported for HashingInputStream
      int read()
      Reads the next byte of data from the underlying input stream and updates the hasher with the byte read.
      int read(byte[] bytes, int off, int len)
      Reads the specified bytes of data from the underlying input stream and updates the hasher with the bytes read.
      void reset()
      reset() is not supported for HashingInputStream.
    • Constructor Detail

      • HashingInputStream

        public HashingInputStream(HashFunction hashFunction,
                                  InputStream in)
        Creates an input stream that hashes using the given HashFunction and delegates all data read from it to the underlying InputStream.

        The InputStream should not be read from before or after the hand-off.

    • Method Detail

      • read

        public int read(byte[] bytes,
                        int off,
                        int len)
                 throws IOException
        Reads the specified bytes of data from the underlying input stream and updates the hasher with the bytes read.
        Overrides:
        read in class  FilterInputStream
        Throws:
        IOException
      • markSupported

        public boolean markSupported()
        mark() is not supported for HashingInputStream
        Overrides:
        markSupported in class  FilterInputStream
        Returns:
        false always
      • mark

        public void mark(int readlimit)
        mark() is not supported for HashingInputStream
      • hash

        public HashCode hash()
        Returns the HashCode based on the data read from this stream. The result is unspecified if this method is called more than once on the same instance.