|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jaulp.file.checksum.ChecksumUtils
public class ChecksumUtils
The Class ChecksumUtils is a utility class for computing checksum from files and byte arrays.
Constructor Summary | |
---|---|
ChecksumUtils()
|
Method Summary | |
---|---|
static java.lang.String |
getChecksum(byte[] bytes,
java.lang.String algorithm)
Gets the checksum from the given byte array with an instance of MessageDigest object. |
static long |
getChecksum(java.io.File file,
boolean crc)
Gets the checksum from the given file. |
static java.lang.String |
getChecksum(java.io.File file,
java.lang.String algorithm)
Gets the checksum from the given file with an instance of MessageDigest object. |
static long |
getCheckSumAdler32(byte[] bytes)
Gets the checksum from the given byte array with an instance of Adler32 object. |
static long |
getCheckSumAdler32(java.io.File file)
Gets the checksum from the given file with an instance of Adler32 object. |
static long |
getCheckSumCRC32(byte[] bytes)
Gets the checksum from the given byte array with an instance of CRC32 object. |
static long |
getCheckSumCRC32(java.io.File file)
Gets the checksum from the given file with an instance of CRC32 object. |
static void |
main(java.lang.String[] args)
The main method. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ChecksumUtils()
Method Detail |
---|
public static void main(java.lang.String[] args) throws java.io.FileNotFoundException, java.io.IOException, java.security.NoSuchAlgorithmException
args
- The args
java.io.IOException
- Signals that an I/O exception has occurred.
java.io.FileNotFoundException
- Is thrown if the file is not found.
java.security.NoSuchAlgorithmException
- Is thrown if the algorithm is not supported or does not
exists.public static long getChecksum(java.io.File file, boolean crc) throws java.io.FileNotFoundException, java.io.IOException
CRC32
object otherwise it is constructed with an
instance of Adler32
object.
file
- The file The file from what to get the checksum.crc
- The crc If the flag crc is true than the CheckedInputStream is
constructed with an instance of CRC32
object otherwise it is constructed with an instance of
Adler32
object.
java.io.FileNotFoundException
- Is thrown if the file is not found.
java.io.IOException
- Signals that an I/O exception has occurred.public static long getCheckSumAdler32(byte[] bytes)
Adler32
object.
bytes
- The byte array.
public static long getCheckSumAdler32(java.io.File file)
Adler32
object.
file
- The file.
public static long getCheckSumCRC32(byte[] bytes)
CRC32
object.
bytes
- The byte array.
public static long getCheckSumCRC32(java.io.File file)
CRC32
object.
file
- The file.
public static java.lang.String getChecksum(byte[] bytes, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
MessageDigest
object.
bytes
- the byte array.algorithm
- the algorithm to get the checksum. This could be for instance
"MD4", "MD5", "SHA-1", "SHA-256", "SHA-384" or "SHA-512".
java.security.NoSuchAlgorithmException
- Is thrown if the algorithm is not supported or does not
exists.public static java.lang.String getChecksum(java.io.File file, java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
MessageDigest
object.
file
- the file.algorithm
- the algorithm to get the checksum. This could be for instance
"MD4", "MD5", "SHA-1", "SHA-256", "SHA-384" or "SHA-512".
java.security.NoSuchAlgorithmException
- Is thrown if the algorithm is not supported or does not
exists.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |