title: Excel file saved by javamail API not readable to apache poi API
body: <p>I receive a file on email which I read using javamail API and save it onto disk directory </p>
  
  <p><strong>MailExtractor.java</strong></p>
  
  <pre><code>    Multipart multiPart = (Multipart) message.getContent(); 
      int numberOfParts = multiPart.getCount(); 
      for (int partCount = 0; partCount &lt; numberOfParts; partCount++) { 
       MimeBodyPart part = (MimeBodyPart) multiPart.getBodyPart(partCount); 
       if (Part.ATTACHMENT.equalsIgnoreCase(part.getDisposition())) { 
         // this part is attachment 
         String fileName = part.getFileName(); 
         attachFiles += fileName + ", "; 
         part.saveFile(saveDir + File.separator + fileName); 
       } 
       else { 
         // this part may be the message content 
         messageContent = part.getContent().toString(); 
       }
      }
  </code></pre>
  
  <p>Now another program polls that disk directory and reads all incoming file. I am only concerned with File extensions - xls/xlsx, so I use apache poi to read the files:</p>
  
  <pre><code>/AvailabilityDirectoryPoller.java 
  FileInputStream fs = new FileInputStream(file); 
   Workbook wb = null; 
   Sheet sheet = null; 
   if(FilenameUtils.getExtension(file.getName()).equalsIgnoreCase("xls")){ 
     wb = new HSSFWorkbook(fs);   //line no 178 
     sheet = (HSSFSheet)wb.getSheetAt(0); 
   } 
   else{ 
     wb = new XSSFWorkbook(fs); 
     sheet = (XSSFSheet)wb.getSheetAt(0); 
   } 
  </code></pre>
  
  <p>This sometimes(read random) results in error as below </p>
  
  <pre><code>[2013-07-18 23:38:32,409] ERROR [AvailabilityDirectoryPoller]: Exception in I/O Reading file 
  java.io.IOException: Your file contains 79 sectors, but the initial DIFAT array at index 1 referenced block # 98. This isn't allowed and  your file is corrupt 
      at org.apache.poi.poifs.storage.BlockAllocationTableReader.&lt;init&gt;(BlockAllocationTableReader.java:103) 
      at org.apache.poi.poifs.filesystem.POIFSFileSystem.&lt;init&gt;(POIFSFileSystem.java:151) 
      at org.apache.poi.hssf.usermodel.HSSFWorkbook.&lt;init&gt;(HSSFWorkbook.java:322) 
      at org.apache.poi.hssf.usermodel.HSSFWorkbook.&lt;init&gt;(HSSFWorkbook.java:303) 
      at com.db.mmrepo.app.avl.bespoke.AvailabilityDirectoryPoller.process(AvailabilityDirectoryPoller.java:178) 
      at com.db.mmrepo.app.avl.bespoke.AvailabilityDirectoryPoller.fileFound(AvailabilityDirectoryPoller.java:73) 
      at org.sadun.util.polling.DefaultListener.receive(DefaultListener.java:43) 
      at com.deltax.util.listener.SignalQueue.run(Unknown Source)
  </code></pre>
  
  <p>If I put open the saved file in MS Excel, it opens woth no warnings/errors.</p>