title: using Java temporary file for XLSX Apache poi
body: <p>.hi, i am trying to create a temporary .xlsx file and write to it using apache poi. i am getting EmptyFileException for creating workbook. this  is the code:</p>
  
  <pre><code>public class Writer{
  File file;
  public File Write(List&lt;FormData&gt; l, Class elementClass)
  {
  
      try {//create temp fiele here
          file = File.createTempFile(elementClass.getSimpleName(),".xlsx");
      } catch (IOException ex) {
          Logger.getLogger(Writer.class.getName()).log(Level.SEVERE, null, ex);
      }
      XSSFWorkbook workbook;
      XSSFSheet sheet;
      if (file.exists()) {
          FileInputStream inputStream;
          try {
              inputStream = new FileInputStream(file);
          } catch (FileNotFoundException ex) {
              throw new AspirinException(AspirinException.Type.INTERNAL_ERROR);
          }
          try {// this line gets error//
              workbook = (XSSFWorkbook) WorkbookFactory.create(inputStream);
          } catch (IOException | InvalidFormatException | EncryptedDocumentException ex) {
              throw new AspirinException(AspirinException.Type.INTERNAL_ERROR);
          }
  
          //...
  </code></pre>
  
  <p>it works fine if i use a real file. but for temp file it doesn't work. please help me with this. thanks</p>