Author: ymartel Date: 2012-03-22 11:18:06 +0100 (Thu, 22 Mar 2012) New Revision: 2308 Url: http://nuiton.org/repositories/revision/nuiton-utils/2308 Log: Fixes #2026 add method to get a File MD5 hash Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java =================================================================== --- trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java 2012-03-19 13:36:02 UTC (rev 2307) +++ trunk/nuiton-utils/src/main/java/org/nuiton/util/MD5InputStream.java 2012-03-22 10:18:06 UTC (rev 2308) @@ -29,6 +29,8 @@ import org.apache.commons.logging.LogFactory; import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.security.DigestInputStream; @@ -86,6 +88,21 @@ /** + * Compute the MD5 for the given {@code input} file. + * + * @param input the File stream to parse + * @return the MD5 hash for the given input File + * @throws IOException if any pb while reading in stream or digest + */ + public static byte[] hash(File input) throws IOException { + InputStream inputStream = new FileInputStream(input); + byte[] result = hash(inputStream); + inputStream.close(); + return result; + } + + + /** * Compute the MD5 for the given {@code input} sring. * * @param input the stream to parse