× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Shane,

ZipEntry.getName() will return the full path name of the file as it is 
stored in the zip file. So all you need to do is just pull the name apart 
with some code like:

        final ZipFile zipFile = new ZipFile(zip-file-name);
        final Enumeration zipList = zipFile.entries();
        while (zipList.hasMoreElements()) {
            final String entryPath;
            final String entryName;
            if (zipEntry.isDirectory()) {
                entryPath = zipEntry.getName();
                entryName = "";
            } else {
                final String fullPathName = zipEntry.getName();
                entryPath = fullPathName.substring(0,
                        fullPathName.lastIndexOf(File.separatorChar) + 1);
                entryName = fullPathName.substring(
                        fullPathName.lastIndexOf(File.separatorChar) + 1);
            }
        }

And if you want the all of the path elements individually, 

String [] pathElements = zipEntry.getName().split(File.separator);

should come close to doing the job.

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx 
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Shane_Cessna@xxxxxxx
Sent: August 19, 2005 08:55
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


_________________________________________________________________
Jeff Furgal / MIMIX Product Architect / Lakeview Technology

furgalj@xxxxxxxxxxxxxxxx

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.