public static long doChecksum(String fileName) {
long checksum = 0L;
try {
CheckedInputStream cis = null;
long fileSize = 0;
try {
// Computer CRC32 checksum
cis = new CheckedInputStream(
new FileInputStream(fileName), new CRC32());
fileSize = new File(fileName).length();
} catch (FileNotFoundException e) {
System.err.println("File not found.");
System.exit(1);
}
byte[] buf = new byte[128];
while(cis.read(buf) >= 0) {
}
checksum = cis.getChecksum().getValue();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}