HTTPClient
Class MD5InputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--HTTPClient.MD5InputStream
- class MD5InputStream
- extends java.io.FilterInputStream
This class calculates a running md5 digest of the data read. When the
stream is closed the calculated digest is passed to a HashVerifier which
is expected to verify this digest and to throw an Exception if it fails.
| Fields inherited from class java.io.FilterInputStream |
in |
| Type | Method |
void |
close()
Close the stream and check the digest. |
int |
read()
|
int |
read(byte[] buf,
int off,
int len)
|
long |
skip(long num)
|
| Methods inherited from class java.io.FilterInputStream |
available, mark, markSupported, read, reset |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MD5InputStream
public MD5InputStream(java.io.InputStream is,
HashVerifier verifier)
- Parameters:
is - the input stream over which the md5 hash is to be calculatedverifier - the HashVerifier to invoke when the stream is closed
read
public int read()
throws java.io.IOException
- Overrides:
read in class java.io.FilterInputStream
read
public int read(byte[] buf,
int off,
int len)
throws java.io.IOException
- Overrides:
read in class java.io.FilterInputStream
skip
public long skip(long num)
throws java.io.IOException
- Overrides:
skip in class java.io.FilterInputStream
close
public void close()
throws java.io.IOException
- Close the stream and check the digest. If the stream has not been
fully read then the rest of the data will first be read (and discarded)
to complete the digest calculation.
- Overrides:
close in class java.io.FilterInputStream
- Throws:
java.io.IOException - if the close()'ing the underlying stream throws
an IOException, or if the expected digest and
the calculated digest don't match.