The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.util.jar  [5 examples]

e380. Listing the Entries of a JAR File Manifest

    try {
        // Open the JAR file
        JarFile jarfile = new JarFile("filename.jar");
    
        // Get the manifest
        Manifest manifest = jarfile.getManifest();
    
        // Get the manifest entries
        Map map = manifest.getEntries();
    
        // Enumerate each entry
        for (Iterator it=map.keySet().iterator(); it.hasNext(); ) {
            // Get entry name
            String entryName = (String)it.next();
    
            // Get all attributes for the entry
            Attributes attrs = (Attributes)map.get(entryName);
    
            // Enumerate each attribute
            for (Iterator it2=attrs.keySet().iterator(); it2.hasNext(); ) {
                // Get attribute name
                Attributes.Name attrName = (Attributes.Name)it2.next();
    
                // Get attribute value
                String attrValue = attrs.getValue(attrName);
            }
        }
    } catch (IOException e) {
    }

 Related Examples
e381. Listing the Main Attributes in a JAR File Manifest
e382. Creating a Manifest for a JAR File
e383. Writing a JAR File Manifest to a File
e384. Creating and Signing a JAR File Using jarsigner


© 2002 Addison-Wesley.