public class ChecksumUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ChecksumUtil.Algorithm
This class encapsulates the valid values for checksum algorithms.
|
| Constructor and Description |
|---|
ChecksumUtil(ChecksumUtil.Algorithm alg) |
| Modifier and Type | Method and Description |
|---|---|
static String |
checksumBytesToString(byte[] digestBytes)
Converts a message digest byte array into a String based
on the hex values appearing in the array.
|
String |
generateChecksum(File file) |
String |
generateChecksum(InputStream inStream)
This method generates checksum of content in arg stream.
|
String |
generateChecksum(String string)
This method generates checksum of content in string.
|
static String |
getChecksum(DigestInputStream digestStream)
Determines the checksum value of a DigestInputStream's underlying
stream after the stream has been read.
|
static byte[] |
getChecksumBytes(DigestInputStream digestStream)
Determines the checksum value of a DigestInputStream's underlying
stream after the stream has been read.
|
static byte[] |
hexStringToByteArray(String s) |
static DigestInputStream |
wrapStream(InputStream inStream,
ChecksumUtil.Algorithm algorithm)
Wraps an InputStream with a DigestInputStream in order to compute
a checksum as the stream is being read.
|
public ChecksumUtil(ChecksumUtil.Algorithm alg)
public String generateChecksum(File file) throws IOException
IOExceptionpublic String generateChecksum(InputStream inStream)
inStream - Content used as target of checksum.public String generateChecksum(String string)
string - Content used as target of checksum.public static DigestInputStream wrapStream(InputStream inStream, ChecksumUtil.Algorithm algorithm)
inStream - The stream to wrapalgorithm - The algorithm used to compute the digestpublic static String getChecksum(DigestInputStream digestStream)
digestStream - public static byte[] getChecksumBytes(DigestInputStream digestStream)
digestStream - public static String checksumBytesToString(byte[] digestBytes)
public static byte[] hexStringToByteArray(String s)
Copyright © 2009-2012 DuraSpace. All Rights Reserved.