This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Getting info from a file inside an ear/war file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting info from a file inside an ear/war file." Watch "Getting info from a file inside an ear/war file." New topic
Author

Getting info from a file inside an ear/war file.

Jeff Strike
Greenhorn

Joined: May 19, 2008
Posts: 15
I have several war files inside an ear.
I need to get info from the mainifest file inside each war file.

I can open the ear file and find the war file entries easy enough with the ZipFile class, but is it possible to open the manifest.mf inside each war file without first unpacking the war from the ear?

Thanks,
-Jeff
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19684
    
  20

You can call the ZipFile's getInputStream(ZipEntry) method. This returns a raw input stream for that entry only. You can then wrap that input stream into a ZipInputStream:
Note how I simply read from the ZipInputStream. That's how ZipInputStream works; after each call to getNextEntry(), the ZipInputStream is reset to start reading from that entry only.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jeff Strike
Greenhorn

Joined: May 19, 2008
Posts: 15
Sweet. I never saw ZipInputStream.

Thanks!
 
 
subject: Getting info from a file inside an ear/war file.