title: How to check that file content really image
body: <p>To detect real file type based on file content(rather than extension) I use apache Tika.</p>
  
  <p>I wrote following code:</p>
  
  <pre><code>    InputStream theInputStream = new FileInputStream("D:\\video.mp4");
      try (InputStream is = theInputStream;
              BufferedInputStream bis = new BufferedInputStream(is);) {
          AutoDetectParser parser = new AutoDetectParser();
          Detector detector = parser.getDetector();
          Metadata md = new Metadata();
          MediaType mediaType = detector.detect(bis, md);
          mediaType.getBaseType().compareTo(MediaType))
          System.out.println(mediaType);
      }
  </code></pre>
  
  <p>this code outputs <code>image/jpeg</code>.</p>
  
  <p>It is truth because I changed file extension.<br>
  Now I want to check that file is image.<br>
  I cannot find enum in MediaType class.<br>
  Now I know only the following way:</p>
  
  <pre><code>mediaType.toString().startsWith("image");
  </code></pre>
  
  <p>But this code looks ugly.<br>
  Can you advise nicer solution?</p>