Java in real examples, Reading Jar file entries

adevedo's picture
0
No votes yet

The Java Archive (JAR) file format enables you to bundle multiple files into a single archive file. Typically a JAR file contains the class files and auxiliary resources associated with applets and applications.

Here we dimonistrate how to use Java to read a Jar file entries one by one, the codes were extracted from real codes of a set of Java libraries

Example 1

Using the constructor JarFile(String name, boolean verify) which creates a JarFile object to read from the specified file name.



Example 2

Using the constructor JarFile(File file) which creates a JarFile object to read from the specified File object. The JarFile will be verified if it is signed.

Another samples uses the above constructor



Example 3





Example 4





Example 5





Example 6