title: Random-access Zip file without writing it to disk
body: <p>I have a 1-2GB zip file with 500-1000k entries. I need to get files by name in fraction of second, without full unpacking. If file is stored on HDD, this works fine:</p>
  
  <pre><code>public class ZipMapper {
      private HashMap&lt;String,ZipEntry&gt; map;
      private ZipFile zf;
  
      public ZipMapper(File file) throws IOException {
          map = new HashMap&lt;&gt;();
          zf = new ZipFile(file);
  
          Enumeration&lt;? extends ZipEntry&gt; en = zf.entries();
          while(en.hasMoreElements()) {
              ZipEntry ze = en.nextElement();
              map.put(ze.getName(), ze);
          }
      }
  
      public Node getNode(String key) throws IOException {
          return Node.loadFromStream(zf.getInputStream(map.get(key)));
      }
  }
  </code></pre>
  
  <p>But what can I do if program downloaded the zip file from Amazon S3 and has its InputStream (or byte array)? While downloading 1GB takes ~1 second, writing it to HDD may take some time, and it is slightly harder to handle multiple files since we don't have HDD garbage collector. </p>
  
  <p>ZipInputStream does not allow to random access to entries.</p>
  
  <p>It would be nice to create a virtual File in memory by byte array, but I couldn't find a way to.</p>