title: How to get the magic number from File in java
body: <p>I have file from UploadedFile button, and I want to print the extension files by use in magic number,</p>
  
  <p>My code:</p>
  
  <pre><code>UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
  byte[] fileByteArray = IOUtils.toByteArray(file.getInputStream());
  </code></pre>
  
  <p>pay attention: Mime type and content file (from file and from the filename) not same to magic number (magic number comes from the first bytes of the inputStream)</p>
  
  <p>How can I do it?</p>