com.metamatrix.core.util
Class ChecksumUtil
java.lang.Object
com.metamatrix.core.util.ChecksumUtil
public class ChecksumUtil
- extends java.lang.Object
This utility class provides mechanisms for computing the checksum.
Method Summary |
static java.util.zip.Checksum |
computeChecksum(java.io.InputStream stream)
Compute and return the checksum (using the default CRC-32 algorithm)
of the contents on the specified stream. |
static long |
computeChecksum(java.io.InputStream stream,
java.util.zip.Checksum algorithm)
Compute the checksum of the contents on the specified stream
using the supplied Checksum algorithm, and modify that
Checksum instance with the checksum value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BUFFER_SIZE
protected static final int BUFFER_SIZE
- See Also:
- Constant Field Values
ChecksumUtil
public ChecksumUtil()
computeChecksum
public static java.util.zip.Checksum computeChecksum(java.io.InputStream stream)
throws java.io.IOException
- Compute and return the checksum (using the default CRC-32 algorithm)
of the contents on the specified stream.
This method closes the stream upon completion.
- Parameters:
stream
- the stream containing the contents for which
the checksum is to be computed; may not be null
- Returns:
- the Checksum for the contents
- Throws:
java.lang.AssertionError
- if stream
is null
java.io.IOException
- if there is an error reading the stream
computeChecksum
public static long computeChecksum(java.io.InputStream stream,
java.util.zip.Checksum algorithm)
throws java.io.IOException
- Compute the checksum of the contents on the specified stream
using the supplied Checksum algorithm, and modify that
Checksum instance with the checksum value.
This method closes the stream upon completion.
- Parameters:
stream
- the stream containing the contents for which
the checksum is to be computed; may not be nullalgorithm
- the checksum algorithm to be used.
- Returns:
- the number of bytes from
stream
that were processed
- Throws:
java.lang.AssertionError
- if stream
or
algorithm
is null
java.io.IOException
- if there is an error reading the stream
Copyright © 2009. All Rights Reserved.