Java CRC crc32(File f)

Here you can find the source of crc32(File f)

Description

crc

License

Open Source License

Declaration

public static long crc32(File f) throws Throwable 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedInputStream;

import java.io.File;
import java.io.FileInputStream;

import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream;

public class Main {
    public static long crc32(File f) throws Throwable {

        CheckedInputStream cis = new CheckedInputStream(new BufferedInputStream(new FileInputStream(f)),
                new CRC32());
        try {//from w w w .java2  s.  c o  m
            while (cis.read() != -1) {
            }
            return cis.getChecksum().getValue();
        } finally {
            cis.close();
        }
    }
}

Related

  1. crc(String tempStr)
  2. crc32(final InputStream input)
  3. crc32(String data)
  4. crcFromStream(InputStream stream)