org.sonatype.aether.util
Class ChecksumUtils

java.lang.Object
  extended by org.sonatype.aether.util.ChecksumUtils

public class ChecksumUtils
extends java.lang.Object

A utility class to assist in the verification and generation of checksums.

Author:
Benjamin Bentmann

Method Summary
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.
static java.lang.String read(java.io.File checksumFile)
          Extracts the checksum from the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public static java.lang.String read(java.io.File checksumFile)
                             throws java.io.IOException
Extracts the checksum from the specified file.

Parameters:
checksumFile - The path to the checksum file, must not be null.
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.IOException
Calculates checksums for the specified file.

Parameters:
dataFile - The file for which to calculate checksums, must not be null.
algos - The names of checksum algorithms (cf. MessageDigest.getInstance(String) to use, must not be null.
Returns:
The calculated checksums, indexed by algorithm name, or the exception that occured while trying to calculate it, never null.
Throws:
java.io.IOException - If the data file could not be read.


Copyright © 2010 Sonatype, Inc.. All Rights Reserved.