Class MD5InputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.security.DigestInputStream
org.nuiton.util.MD5InputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
MD5InputStream, a subclass of FilterInputStream implementing MD5
functionality on a stream.
- Author:
- Tony Chemit - chemit@codelutin.com
-
Field Summary
FieldsFields inherited from class DigestInputStream
digestFields inherited from class FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static MessageDigestlongbyte[]hash()Returns array of bytes representing hash of the stream as finalized for the current state.static byte[]Compute the MD5 for the giveninputfile.static byte[]hash(InputStream input) Compute the MD5 for the giveninput.static byte[]Compute the MD5 for the giveninputsring.intread()intread(byte[] bytes, int offset, int length) Methods inherited from class DigestInputStream
getMessageDigest, on, setMessageDigest, toStringMethods inherited from class FilterInputStream
available, close, mark, markSupported, read, reset, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Field Details
-
streamLength
protected long streamLengthlength of readed stream
-
-
Constructor Details
-
MD5InputStream
-
-
Method Details
-
getMD5Digest
- Throws:
IllegalStateException
-
hash
Compute the MD5 for the giveninput. Note: The the stream will be closed after calling the method even if something was wrong.- Parameters:
input- the stream to parse- Returns:
- the MD5 hash for the given input stream
- Throws:
IOException- if any pb while reading in stream or digest
-
hash
Compute the MD5 for the giveninputfile.- Parameters:
input- the File stream to parse- Returns:
- the MD5 hash for the given input File
- Throws:
IOException- if any pb while reading in stream or digest
-
hash
Compute the MD5 for the giveninputsring.- Parameters:
input- the stream to parse- Returns:
- the MD5 hash for the given input String
- Throws:
IOException- if any pb while reading in stream or digest
-
read
- Overrides:
readin classDigestInputStream- Throws:
IOException
-
read
- Overrides:
readin classDigestInputStream- Throws:
IOException
-
hash
public byte[] hash()Returns array of bytes representing hash of the stream as finalized for the current state.- Returns:
- hash
- See Also:
-
getStreamLength
public long getStreamLength()
-