title: Reading a zip file within a jar file
body: <p>Previously we had some zip files within our web application. We would want to pares a specific text document within the zip file. This wasn't a problem:</p>
  
  <pre><code>URL url = getClass().getResource(zipfile);
  ZipFile zip = new ZipFile(url.getFile().replaceAll("%20", " "));     
  Entry entry = zip.getEntry("file.txt");
  
  InputStream is = zip.getInputStream(entry);
  BufferedReader reader = new BufferedReader(new InputStreamReader(is));
  
  String line = reader.readLine();
  while (line != null) {
      // do stuff
  }
  </code></pre>
  
  <p>However we've moved these zip files into another module and want to package them within a jar. Unfortunately, creating the <code>ZipFile</code> now fails. I can get an <code>InputStream</code> for the zip: but I have no way of getting an input stream for the entry itself.</p>
  
  <pre><code>InputStream is = getClass().getResourceAsStream(zipfile);
  ZipInputStream zis = new ZipInputStream(is);
  
  ZipEntry entry = zis.getNextEntry();
  while (entry != null &amp;&amp; !entry.getName().equals("file.txt")) {
      entry = zis.getNextEntry();
  }
  </code></pre>
  
  <p>but I have no way of getting an input stream for the entry itself. I tried finding the length of the entry and getting the next n bytes from the <code>ZipInputStream</code> but this didn't work for me. It seemed all bytes read were 0.</p>
  
  <p>Is there a way round this or am I going to have to move the zip files back into the core project?</p>