title: read excel file(which is in classpath ) via apache poi
body: <p>I am trying to read (using apache poi) .xlsx file  which is not in file system but in classpath. I am using maven - so it is in resources folder. </p>
  
  <p>my code is -</p>
  
  <pre><code>InputStream resourceAsStream = MyReader.class.getClassLoader().getResourceAsStream("test.xlsx");
     Workbook wb = new XSSFWorkbook(resourceAsStream);
  </code></pre>
  
  <p>I am getting this exception.</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: MALFORMED
          at java.util.zip.ZipCoder.toString(ZipCoder.java:58) ~[?:1.7.0_51]
          at java.util.zip.ZipInputStream.readLOC(ZipInputStream.java:297) ~[?:1.7.0_51]
          at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:121) ~[?:1.7.0_51]
          at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.&lt;init&gt;(ZipInputStreamZipEntrySource.java:51) ~[poi
  a3]
          at org.apache.poi.openxml4j.opc.ZipPackage.&lt;init&gt;(ZipPackage.java:88) ~[poi-ooxml-3.11-beta3.jar:3.11-beta3]
          at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:272) ~[poi-ooxml-3.11-beta3.jar:3.11-beta3]
          at org.apache.poi.util.PackageHelper.open(PackageHelper.java:37) ~[poi-ooxml-3.11-beta3.jar:3.11-beta3]
  </code></pre>
  
  <p>When I read same file from file system everything is fine. 
  Is there a bug in my code or do I miss understand something? </p>
  
  <p>UPDATE1:  This is in web app, so code is deployed in tomcat 7.</p>
  
  <p>UPDATE2:  when I read same file in this way - it works.</p>
  
  <pre><code>File file = new File("C:\\Users\\.....\\test.xlsx");
   FileInputStream fileInputStream = new FileInputStream(file);
  
   Workbook wb = new XSSFWorkbook(fileInputStream);
  </code></pre>
  
  <p>thanks</p>