title: How to know file type without extension
body: <p>While trying to come-up with a servlet based application to read files and manipulate them (image type conversion) here is a question that came up to me:</p>
  
  <ol>
  <li>Is it possible to inspect a file content and know the filetype?</li>
  <li>Is there a standard that specifies that each file MUST provide some type of marker in their content so that the application will not have to rely on the file extension constraints?</li>
  </ol>
  
  <p>Consider an application scenario:</p>
  
  <p>I am creating an application that will be able to convert different file formats to a set of output formats. Say user uploads an PDF, my application can suggest that the possible conversion formats are microsoft word or TIFF or JPEG etc.</p>
  
  <p>As my application will gradually support different file formats (over a period of time), I want my application to inspect the input file instead of having the user to specify the format. And suggest to user the possible formats of output.</p>
  
  <p>I understand this is an open ended, broad question. Please let me know if it needs to be modified.</p>
  
  <p>Thanks,
  Ayusman</p>