Here you can find the source of md5File(File file)
public static String md5File(File file)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.security.MessageDigest; import org.apache.commons.codec.binary.Hex; public class Main { public static String md5File(File file) { if (!file.isFile()) { return null; }//w w w. ja v a 2 s. co m MessageDigest digest = null; FileInputStream in = null; byte buffer[] = new byte[1024]; int len; try { digest = MessageDigest.getInstance("MD5"); in = new FileInputStream(file); while ((len = in.read(buffer, 0, 1024)) != -1) { digest.update(buffer, 0, len); } } catch (Exception e) { return null; } finally { if (in != null) { try { in.close(); } catch (IOException e) { //do nothing } } } return new String(Hex.encodeHex(digest.digest())); } }