Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I read .zip and .jar file using standard Java classes?

classes file Java read standard
0
Posted

How can I read .zip and .jar file using standard Java classes?

0

Location: http://www.jguru.com/faq/view.jsp?EID=41035 Created: Apr 27, 2000 Modified: 2001-08-18 17:12:00.941 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Khoivu N (http://www.jguru.com/guru/viewbio.jsp?EID=32600 The ZIP and JAR reading classes are found in the java.util.zip and java.util.jar packages respectively. The following demonstrates reading from a ZIP file, listing all the files in the zip and displaying the contents of the first file in the zip. JAR file reading is similar, just with different classes and having a manifest. import java.util.zip.*; import java.util.*; import java.io.*; public class ZipExample { public static void main(String args[]) { try { ZipFile zf = new ZipFile(“the.zip”); Enumeration entries = zf.entries(); String first = null; while (entries.hasMoreElements()) { ZipEntry ze = (ZipEntry)entries.nextElement(); System.out.println(“Entry ” + ze.getName()); if (first == null) first = ze.getName(); } ZipEntry

0

Location: http://www.jguru.com/faq/view.jsp?EID=41035 Created: Apr 27, 2000 Modified: 2001-08-18 17:12:00.941 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Khoivu N (http://www.jguru.com/guru/viewbio.jsp?EID=32600 The ZIP and JAR reading classes are found in the java.util.zip and java.util.jar packages respectively. The following demonstrates reading from a ZIP file, listing all the files in the zip and displaying the contents of the first file in the zip. JAR file reading is similar, just with different classes and having a manifest.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.