import java.io.*; import java.util.zip.CheckedInputStream; import java.util.zip.CRC32; public class ChecksumCRC32 { public void checkSum(String file){ try{ FileInputStream fis = null; CheckedInputStream cis = null; CRC32 crc = null; long sizeOfFile = 0; try{ fis = new FileInputStream(file); crc = new CRC32(); cis = new CheckedInputStream(fis, crc); sizeOfFile = new File(file).length(); } catch (Exception e){ System.out.println("File Not found "); System.exit(1); } byte[] buffer = new byte[100]; while(cis.read(buffer)>=0){ long checksum = cis.getChecksum().getValue(); System.out.println(checksum + " " + sizeOfFile + " " + file); } } catch(IOException e){ System.out.println("the exception has been thrown" + e); System.exit(1); } } public static void main(String[] args) { ChecksumCRC32 crc = new ChecksumCRC32(); if(args.length!= 1){ System.out.println("Please enter the valid file name : " ); } else{ crc.checkSum(args[0]); } } }