Package com.backblaze.b2.util
Class B2Sha1InputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.backblaze.b2.util.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)
-
-
-
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 classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] buffer, int offset, int length) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
skip
public long skip(long bytesToSkip) throws java.io.IOException
- Overrides:
skip
in classjava.io.InputStream
- Throws:
java.io.IOException
-
-