May 26

Java provides the ZipInputStream class for reading from a zip file. Heres a general example of its usage

File file = new File("");
ZipInputStream zin = new ZipInputStream(new FileInputStream(file));
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
   String filename = ze.getName();
   if (!ze.isDirectory()) {
        // Read file contents from 'zin'
        // For example you could read from zin and write it to a FileOutputStream

The same can be used to read the contents of a jar file.

written by objects \\ tags: , , , , ,

Leave a Reply

You must be logged in to post a comment.