Package org.eclipse.aether.util
Class ChecksumUtils
- java.lang.Object
-
- org.eclipse.aether.util.ChecksumUtils
-
public final class ChecksumUtils extends java.lang.ObjectA utility class to assist in the verification and generation of checksums.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateChecksumUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.Object>calc(byte[] dataBytes, java.util.Collection<java.lang.String> algos)static java.util.Map<java.lang.String,java.lang.Object>calc(java.io.File dataFile, java.util.Collection<java.lang.String> algos)Calculates checksums for the specified file.private static java.util.Map<java.lang.String,java.lang.Object>calc(java.io.InputStream data, java.util.Collection<java.lang.String> algos)static java.lang.Stringread(java.io.File checksumFile)Extracts the checksum from the specified file.static java.lang.StringtoHexString(byte[] bytes)Creates a hexadecimal representation of the specified bytes.
-
-
-
Method Detail
-
read
public static java.lang.String read(java.io.File checksumFile) throws java.io.IOExceptionExtracts the checksum from the specified file.- Parameters:
checksumFile- The path to the checksum file, must not benull.- Returns:
- The checksum stored in the file, never
null. - Throws:
java.io.IOException- If the checksum does not exist or could not be read for other reasons.
-
calc
public static java.util.Map<java.lang.String,java.lang.Object> calc(java.io.File dataFile, java.util.Collection<java.lang.String> algos) throws java.io.IOExceptionCalculates checksums for the specified file.- Parameters:
dataFile- The file for which to calculate checksums, must not benull.algos- The names of checksum algorithms (cf.MessageDigest.getInstance(String)to use, must not benull.- Returns:
- The calculated checksums, indexed by algorithm name, or the exception that occurred while trying to
calculate it, never
null. - Throws:
java.io.IOException- If the data file could not be read.
-
calc
public static java.util.Map<java.lang.String,java.lang.Object> calc(byte[] dataBytes, java.util.Collection<java.lang.String> algos) throws java.io.IOException- Throws:
java.io.IOException
-
calc
private static java.util.Map<java.lang.String,java.lang.Object> calc(java.io.InputStream data, java.util.Collection<java.lang.String> algos) throws java.io.IOException- Throws:
java.io.IOException
-
toHexString
public static java.lang.String toHexString(byte[] bytes)
Creates a hexadecimal representation of the specified bytes. Each byte is converted into a two-digit hex number and appended to the result with no separator between consecutive bytes.- Parameters:
bytes- The bytes to represent in hex notation, may be benull.- Returns:
- The hexadecimal representation of the input or
nullif the input wasnull.
-
-