Here you can find the source of md5file(File file)
public static String md5file(File file) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.math.BigInteger; import java.security.MessageDigest; public class Main { public static String md5file(File file) throws Exception { byte[] _bytes = null; InputStream is = new FileInputStream(file); MessageDigest digest = MessageDigest.getInstance("MD5"); byte[] buffer = new byte[8192]; int read = 0; while ((read = is.read(buffer)) > 0) { digest.update(buffer, 0, read); }//from w w w .j a va 2s . co m _bytes = digest.digest(); if (is != null) { is.close(); is = null; } return new BigInteger(1, _bytes).toString(16); } }