title: How to get content type of a file which has no extension?
body: <p>I have saved all types of file without extension.  When reading through Java code, how to get content type of file?</p>
  
  <pre><code>File file = "/admin/sun"
  byte[] pdfByteArray = FileUtils.readFileToByteArray(file);
  if (fileName.endsWith(".pdf")) {
      response.setContentType("application/pdf");
  } else {
      response.setContentType("image/jpeg");
  }
  response.getOutputStream().write(pdfByteArray);
  response.getOutputStream().flush();
  </code></pre>
  
  <p>What is if the file extension .pdf or .jpeg it is working then without extension how to get content-type?</p>