The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.util.zip  [9 examples] > Checksums  [2 examples]

e457. Calculating the Checksum of a File

    try {
        // Compute Adler-32 checksum
        CheckedInputStream cis = new CheckedInputStream(
            new FileInputStream("filename"), new Adler32());
        byte[] tempBuf = new byte[128];
        while (cis.read(tempBuf) >= 0) {
        }
        long checksum = cis.getChecksum().getValue();
    } catch (IOException e) {
    }

 Related Examples
e456. Calculating the Checksum of a Byte Array

See also: GZIP    ZIP   


© 2002 Addison-Wesley.