Here you can find the source of md5(File f)
public static String md5(File f)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.security.DigestInputStream; import java.security.MessageDigest; public class Main { public static String md5(File f) { MessageDigest md = null;/*from w ww . j ava 2s . co m*/ InputStream is = null; try { md = MessageDigest.getInstance("MD5"); is = new FileInputStream(f); is = new DigestInputStream(is, md); byte[] buffer = new byte[8192]; while (is.read(buffer) != -1) { } } catch (Exception e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } byte[] digest = md.digest(); return digest.toString(); } }