com.netease.cloud.services.nos.internal
public class ChecksumValidatingInputStream extends FilterInputStream
in
Constructor and Description |
---|
ChecksumValidatingInputStream(InputStream in,
byte[] expectedChecksum,
String sourceObject)
Constructs a new InputStream that wraps an existing InputStream and
calculates a client-side MD5 checksum as the user reads data from the
stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
available, mark, markSupported, reset, skip
public ChecksumValidatingInputStream(InputStream in, byte[] expectedChecksum, String sourceObject) throws NoSuchAlgorithmException
in
- The InputStream to wrap, containing the content to calculate
the MD5 checksum for.expectedChecksum
- The expected MD5 checksum for the data.sourceObject
- A text description of the original source object in Nos; only
used in an error message to give the user more context about
what failed if data corruption is detected.NoSuchAlgorithmException
- If the running JVM doesn't support MD5 MessageDigests.public int read() throws IOException
read
in class FilterInputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class FilterInputStream
IOException
public int read(byte[] b) throws IOException
read
in class FilterInputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class FilterInputStream
IOException
Copyright © 2017. All Rights Reserved.