import java.io.File;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.DigestInputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Digest {
	private static String[] algorithms = {"MD5", "SHA-1", "SHA-256"};
	public static void main(String[] args) {
		if (args.length < 2 || args[0].equals("--help")) {
			printUsageAndExit();
			return;
		}
		String algorithm = args[0];
		// Main loop.
		for (int i = 1; i < args.length; i++) {
			try {
				File input = new File(args[i]);
				byte[] digest = computeDigest(input, algorithm);
				printDigest(digest);
			} catch (IOException ex) {
				System.err.println("Warning: Error reading file: " + args[i]);
			} catch (NoSuchAlgorithmException ex) {
				System.err.println("Unknown algorithm: " + algorithm);
				printUsageAndExit();
				return;
			}
		}
	}

	private static byte[] computeDigest(File input, String algorithm)
	        throws IOException, NoSuchAlgorithmException {
		try (DigestInputStream stream = new DigestInputStream(
		        new BufferedInputStream(new FileInputStream(input)),
		        MessageDigest.getInstance(algorithm))) {
			while (stream.read() != -1);
			MessageDigest digest = stream.getMessageDigest();
			return digest.digest();
		}
	}

	private static void printDigest(byte[] digest) {
		for (int i = 0; i < digest.length; i++) {
			System.out.printf("%x", digest[i]);
		}
		System.out.println();
	}

	private static void printUsageAndExit() {
		System.err.println("Usage: java Digest <function_name> <file1> file2> ...\n" +
		                   "    <function_name> options include: ");
		for (String algorithm : algorithms) {
			System.err.println("                                    " + algorithm);
		}
		System.exit(1);
	}
}
@@ -665,16 +665,62 @@
 t(digest
+, args%5Bi%5D);%0A%09%09%09%09System.out.println(%22 %22 + input
 );%0A%09%09%09%7D 
@@ -1423,16 +1423,33 @@
 %5D digest
+, String fileName
 ) %7B%0A%09%09fo
@@ -1511,16 +1511,18 @@
 rintf(%22%25
+02
 x%22, dige
@@ -1537,32 +1537,8 @@
 %09%09%7D%0A
-%09%09System.out.println();%0A
 %09%7D%0A%0A

Add file names to output