code: public static String hash(final File aFile, final String aAlgorithm) throws NoSuchAlgorithmException,
              IOException {
          final MessageDigest md = MessageDigest.getInstance(aAlgorithm);
          final FileInputStream inStream = new FileInputStream(aFile);
          final DigestInputStream mdStream = new DigestInputStream(inStream, md);
          final byte[] bytes = new byte[8192];
          int bytesRead = 0;
  
          while (bytesRead != -1) {
              bytesRead = mdStream.read(bytes);
          }
  
          final Formatter formatter = new Formatter();
  
          for (final byte bite : md.digest()) {
              formatter.format("%02x", bite);
          }
  
          IOUtils.closeQuietly(mdStream);
  
          final String hash = formatter.toString();
  
          formatter.close();
  
          return hash;
      }
docs: Get a hash for a supplied file.
  
  @param aFile A file to get a hash for
  @param aAlgorithm A hash algorithm supported by <code>MessageDigest</code>
  @return A hash string
  @throws NoSuchAlgorithmException If the supplied algorithm isn't supported
  @throws IOException If there is trouble reading the file