Class B2Sha1InputStream

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

    public class B2Sha1InputStream
    extends java.io.InputStream
    Wrapper for an InputStream that computes the SHA1 of the bytes going through it.
    • Constructor Summary

      Constructors 
      Constructor Description
      B2Sha1InputStream​(java.io.InputStream in)
      Initializes a stream that will digest all of the bytes read and skipped.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      byte[] digest()
      Returns the SHA1 of the bytes processed so far.
      java.lang.String hexDigest()
      Returns the SHA1 if the bytes processed so far, as a hex string.
      int read()  
      int read​(byte[] buffer, int offset, int length)  
      long skip​(long bytesToSkip)  
      • Methods inherited from class java.io.InputStream

        mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, transferTo
      • Methods inherited from class java.lang.Object

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

      • B2Sha1InputStream

        public B2Sha1InputStream​(java.io.InputStream in)
        Initializes a stream that will digest all of the bytes read and skipped.
    • Method Detail

      • digest

        public byte[] digest()
        Returns the SHA1 of the bytes processed so far.
      • hexDigest

        public java.lang.String hexDigest()
        Returns the SHA1 if the bytes processed so far, as a hex string.
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] buffer,
                        int offset,
                        int length)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • skip

        public long skip​(long bytesToSkip)
                  throws java.io.IOException
        Overrides:
        skip in class java.io.InputStream
        Throws:
        java.io.IOException