Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>zipFile.getInputStream(ZipEntry entry)</code> will return you the inputstream for the specific entry.</p> <p>Check out the <a href="http://docs.oracle.com/javase/6/docs/api/java/util/zip/ZipFile.html#getInputStream(java.util.zip.ZipEntry)" rel="nofollow">javadocs</a> for <code>ZipFile.getInputStream()</code> - <a href="http://docs.oracle.com/javase/6/docs/api/java/util/zip/ZipFile.html#getInputStream(java.util.zip.ZipEntry)" rel="nofollow">http://docs.oracle.com/javase/6/docs/api/java/util/zip/ZipFile.html#getInputStream(java.util.zip.ZipEntry)</a>.</p> <p><strong>Update:</strong></p> <p>I misread your question. For using the <code>ZipInputStream</code>, there is sample code on Oracle's website (<a href="http://java.sun.com/developer/technicalArticles/Programming/compression/" rel="nofollow">http://java.sun.com/developer/technicalArticles/Programming/compression/</a>) that shows you how to read from the stream. See the first code sample: Code </p> <ul> <li>Sample 1: UnZip.java. </li> </ul> <p>Copying here, it is reading from the entry and writing it directly to a file, but you could replace that with whatever logic you need:</p> <pre><code>ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis)); ZipEntry entry; while((entry = zis.getNextEntry()) != null) { System.out.println("Extracting: " +entry); int count; byte data[] = new byte[BUFFER]; // write the files to the disk FileOutputStream fos = new FileOutputStream(entry.getName()); dest = new BufferedOutputStream(fos, BUFFER); while ((count = zis.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload