title: unable to determine the MIME type of a file
body: <p>I'm new to Java and is trying to learn how to determine the MIME type of a file. I'm using Mac OS. Below is the code I came up with. However, when I run the code, the IDE output error:</p>
  
  <pre><code>'/Users/justin/Desktop/Codes Netbean/JavaRandom/xanadu.txt' has an unknown filetype.
  </code></pre>
  
  <p>Why is this happening? The file does exist. Am I doing something wrong?</p>
  
  <pre><code>public class DeterminingMIMEType {
  
      public static void main(String[] args) {
  
          Path filename = Paths.get("/Users/justin/Desktop/Codes Netbean/JavaRandom/xanadu.txt");
  
          try {
              String type = Files.probeContentType(filename);
              if (type == null) {
                  System.err.format("'%s' has an" + " unknown filetype.%n", filename);
              } else if (!type.equals("text/plain")) {
                  System.err.format("'%s' is not" + " a plain text file.%n", filename);
              }
          } catch (IOException x) {
              System.err.println(x);
          }
      }
  }
  </code></pre>