Here you can find the source of getManifest(final String jarFileName)
Parameter | Description |
---|---|
jarFileName | the jar file name |
Parameter | Description |
---|---|
IOException | I/O Exception |
public static Manifest getManifest(final String jarFileName) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; import java.util.jar.Manifest; import java.util.jar.JarFile; import java.util.zip.ZipEntry; public class Main { /**//from w w w .j av a 2 s. c om * Gets the manifest object from jar file. * * @param jarFileName the jar file name * @return the manifest object * @throws IOException I/O Exception */ public static Manifest getManifest(final String jarFileName) throws IOException { final JarFile jarFile = new JarFile(jarFileName); final Manifest manifest = getManifest(jarFile); jarFile.close(); return manifest; } /** * Gets the manifest object from jar file. * * @param jarFile the jar file * @return the manifest object * @throws IOException I/O Exception */ public static Manifest getManifest(final JarFile jarFile) throws IOException { Manifest manifest = null; ZipEntry zipEntry = jarFile.getEntry("META-INF/MANIFEST.MF"); if (zipEntry == null) { zipEntry = jarFile.getEntry("meta-inf/manifest.mf"); } if (zipEntry != null) { final InputStream is = jarFile.getInputStream(zipEntry); manifest = new Manifest(is); is.close(); } return manifest; } }