41 import java.nio.file.*;
42 import java.io.IOException;
45 public static void main(String[] args)
throws IOException {
46 if (args.length == 0) {
47 System.err.println(
"usage: java FileType file...");
50 for (String arg: args) {
51 Path file = Paths.get(arg);
53 if (Files.isDirectory(file)) {
56 type = Files.probeContentType(file);
58 type =
"<not recognized>";
60 System.out.format(
"%s\t%s%n", file, type);