It is simple example for generating checksum in java


String myFile= "c:\\myFile.TXT";

MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
FileInputStream fileInputStream = new FileInputStream(myFile);
byte[] dataBytes = new byte[1024];

int nread = 0;

while ((nread = fileInputStream.read(dataBytes)) != -1) {
messageDigest.update(dataBytes, 0, nread);
};

byte[] mdbytes = messageDigest.digest();

StringBuffer sb = new StringBuffer("");
for (int i = 0; i < mdbytes.length; i++) { sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1)); } System.out.println(sb.toString());

In the en you will see checksum