Code example for Checksum

Methods: getValue, reset

0
  /* verify checksum for the chunk. 
   * @throws ChecksumException if there is a mismatch 
   */ 
  private void verifySum(long errPos) throws ChecksumException {
    long crc = getChecksum();
    long sumValue = sum.getValue();
    sum.reset();
    if (crc != sumValue) {
      throw new ChecksumException( 
          "Checksum error: "+file+" at "+errPos, errPos);
    } 
  } 
   
  /* calculate checksum value */ 
  private long getChecksum() { 
    return checksum2long(checksum);
  } 
 
  /** Convert a checksum byte array to a long */ 
  static public long checksum2long(byte[] checksum) {
    long crc = 0L;