检索清单对象,或者如果在给定的Jar文件中找不到清单,则创建一个空的清单对象
/*nowjava.com - 时 代 Java*/ //package com.nowjava; import java.io.File; import java.io.IOException; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.Manifest; public class Main { public static final String META_INF = "META-INF"; /** * Retrieves a Manifest object or creates an empty Manifest object * if the Manifest is not found in the given Jar file * @param jarFile * @return * @throws IOException */ public static Manifest getManifest(File jarFile) throws IOException {/** 时 代 J a v a 公 众 号 - N o w J a v a . c o m 提 供 **/ JarFile jar = new JarFile(jarFile); String manifestPath = META_INF + "/MANIFEST.MF"; JarEntry jarEntry = jar.getJarEntry(manifestPath); if (jarEntry != null) { Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { jarEntry = (JarEntry) entries.nextElement(); if (manifestPath.equalsIgnoreCase(jarEntry.getName())) { break; } else { jarEntr