Java Jar Manifest getManifest(ZipFile zip)

Here you can find the source of getManifest(ZipFile zip)

Description

Use this utility to read Manifest from a JarFile or ZipFile due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6735255

License

Apache License

Parameter

Parameter Description
zip a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static Manifest getManifest(ZipFile zip) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;

import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class Main {
    /**// ww  w. j a  v a 2  s  .  co  m
     * Use this utility to read Manifest from a JarFile or ZipFile
     * due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6735255
     * 
     * @param zip
     * @return
     * @throws IOException
     */
    public static Manifest getManifest(ZipFile zip) throws IOException {
        ZipEntry entry = zip.getEntry("META-INF/MANIFEST.MF");
        if (entry == null)
            return null;

        InputStream in = zip.getInputStream(entry);
        try {
            return new Manifest(in);
        } finally {
            // explicitly close due to 
            // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6735255
            in.close();
        }
    }
}

Related

  1. getManifest(File pluginFile)
  2. getManifest(final String jarFileName)
  3. getManifest(JarFile pluginJarFile)
  4. getManifest(String className)
  5. getManifest(String path)
  6. getManifest(ZipFile zipFile)
  7. getManifestAttribute(InputStream in, String attr)
  8. getManifestAttribute(Manifest m)
  9. getManifestAttribute(String jarUrl, String attribute)