Here is a program I wrote to test the java.util.zip functionality.  Could
you just iterate through the zip file and do logical comparisons vs. doing a
pseudo search?

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class ParseZipFile {

    public static final void main(String[] args) {
        Enumeration entries;
        ZipFile zipFile;

        try {
            zipFile = new ZipFile("c:/temp/zipfolder1.zip");

            entries = zipFile.entries();

            while (entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry) entries.nextElement();

                if (entry.isDirectory()) {
                    System.err.println("Extracting directory: " +
entry.getName());
                    (new File("c:/temp/" + entry.getName())).mkdir();
                    continue;
                }

                System.err.println("Extracting file: " + entry.getName());
                String actualFile =
entry.getName().substring(entry.getName().lastIndexOf("/") + 1);
                copyInputStream(zipFile.getInputStream(entry), new
BufferedOutputStream(new FileOutputStream("c:/temp/"
                        + actualFile)));
            }

            zipFile.close();
        } catch (IOException ioe) {
            System.err.println("Unhandled exception:");
            ioe.printStackTrace();
            return;
        }
    }

    public static final void copyInputStream(InputStream in, OutputStream
out) throws IOException {
        byte[] buffer = new byte[1024];
        int len;

        while ((len = in.read(buffer)) >= 0)
            out.write(buffer, 0, len);

        in.close();
        out.close();
    }

} 

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Shane_Cessna@xxxxxxx
Sent: Friday, August 19, 2005 10:55 AM
To: Java Programming on and around the iSeries / AS400
Subject: Zip file question...

I've got a Zip file on our IFS that I'd like to open and extract only
certain files...you know how in WinZip, it lists the files like this:

Name   | Type    | Size    | Ratio    | Packed    | Path

I'd like to be able to extract only records with a specific Path
attribute...I've looked all through the java.util.zip javadocs and have
found a whole lot of nuthin...

Thanks in advance.

Shane
--
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/java400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.