## org.codehaus.plexus.digest
Class ChecksumFile

    java.lang.Object
      org.codehaus.plexus.digest.ChecksumFile

    public class ChecksumFile

extends java.lang.Object

ChecksumFile

Version:
  $Id: ChecksumFile.java 6294 2007-04-13 15:42:34Z joakime $
Author:
  Joakim Erdfelt

Constructor Summary
`ChecksumFile()`

Method Summary
`java.io.File` `createChecksum(java.io.File referenceFile, Digester digester)` Creates a checksum file of the provided referenceFile.
`boolean` `isValidChecksum(java.io.File checksumFile)` Given a checksum file, check to see if the file it represents is valid according to the checksum.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ChecksumFile

    public ChecksumFile()

Method Detail

### isValidChecksum

    public boolean isValidChecksum(java.io.File checksumFile)
                            throws DigesterException,
                                   java.io.FileNotFoundException,
                                   java.io.IOException

  Given a checksum file, check to see if the file it represents is valid according to the checksum.

  <lh>Terminology:</lh>
  Checksum File
    The file that contains the previously calculated checksum value for the reference file. This is a text file with the extension ".sha1" or ".md5", and contains a single entry consisting of an optional reference filename, and a checksum string.
  Reference File
    The file that is being referenced in the checksum file.

  NOTE: Only supports single file checksums of type MD5 or SHA1.

  Parameters:
    `checksumFile` - the checksum file (must end in ".sha1" or ".md5")
  Returns:
    true if the checksum is valid for the file it represents.
  Throws:
    `DigesterException` - if there is a digester problem during the check of the reference file.
    `java.io.FileNotFoundException` - if the checksumFile itself or the file it refers to is not found.
    `java.io.IOException` - if the reading of the checksumFile or the file it refers to fails.

### createChecksum

    public java.io.File createChecksum(java.io.File referenceFile,
                                       Digester digester)
                                throws DigesterException,
                                       java.io.IOException

  Creates a checksum file of the provided referenceFile.

  Parameters:
    `referenceFile` - the file to checksum.
    `digester` - the digester to use.
  Returns:
    the checksum File that was created.
  Throws:
    `DigesterException` - if there was a problem calculating the checksum of the referenceFile.
    `java.io.IOException` - if there was a problem either reading the referenceFile, or writing the checksum file.

Copyright © 2011. All Rights Reserved.