public static MD5Hash computeMd5ForFile ( File dataFile ) throws IOException { InputStream in = new FileInputStream ( dataFile ) ; try { MessageDigest digester = MD5Hash . getDigester ( ) ; DigestInputStream dis = new DigestInputStream ( in , digester ) ; IOUtils . copyBytes ( dis , new IOUtils . NullOutputStream ( ) , 128 * 1024 , false ) ; return new MD5Hash ( digester . digest ( ) ) ; } finally { IOUtils . closeStream ( in ) ; } }
Read dataFile and compute its MD5 checksum .