Here you can find the source of getChecksum(String filePath)
public static String getChecksum(String filePath) throws FileNotFoundException, IOException
//package com.java2s; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.util.zip.CRC32; import java.util.zip.CheckedInputStream; public class Main { public static String getChecksum(String filePath) throws FileNotFoundException, IOException { FileInputStream file = new FileInputStream(filePath); CheckedInputStream check = new CheckedInputStream(file, new CRC32()); BufferedInputStream in = new BufferedInputStream(check); String checkSum = ""; while (in.read() != -1) { // Read file in completely }/*from w w w.ja v a2 s . co m*/ if (in != null) { in.close(); } if (file != null) file.close(); if (check != null) { checkSum = String.valueOf(check.getChecksum().getValue()); check.close(); } return checkSum; } }