code: public static byte[] getChecksum(String algorithm, File file) throws NoSuchAlgorithmException, IOException {
          final MessageDigest md = MessageDigest.getInstance(algorithm);
          try (FileInputStream fis = new FileInputStream(file);
                  FileChannel ch = fis.getChannel()) {
              final ByteBuffer buf = ByteBuffer.allocateDirect(8192);
              int b = ch.read(buf);
              while (b != -1 && b != 0) {
                  buf.flip();
                  final byte[] bytes = new byte[b];
                  buf.get(bytes);
                  md.update(bytes, 0, b);
                  buf.clear();
                  b = ch.read(buf);
              }
              return md.digest();
          }
      }
docs: <p>
  Creates the cryptographic checksum of a given file using the specified
  algorithm.</p>
  
  @param algorithm the algorithm to use to calculate the checksum
  @param file the file to calculate the checksum for
  @return the checksum
  @throws java.io.IOException when the file does not exist
  @throws java.security.NoSuchAlgorithmException when an algorithm is specified that does
  not exist