public static byte[] checksum(File file) throws IOException {
        try {
            InputStream in = new FileInputStream(file);
            byte[] buffer = new byte[2048];
            MessageDigest complete = MessageDigest.getInstance("MD5");

            try {
                int n;

                do {
                    n = in.read(buffer);

                    if (n > 0) {
                        complete.update(buffer, 0, n);
                    }
                } while (n != -1);
            } finally {
                in.close();
            }

            return complete.digest();
        } catch (NoSuchAlgorithmException ex) {
            throw new IOException("Could not create checksum " + file, ex);
        }
    }
Creates the MD5 checksum for the given file.

@param   file  the file.

@return  the checksum.
antlr4-maven-plugin/src/main/java/org/antlr/mojo/antlr4/MojoUtils.java