List of utility methods to do Jar Manifest
String | getManifestEntryValue(IResource manifest, String entryKey) get Manifest Entry Value if (manifest instanceof IFile) { String content = getFileContent((IFile) manifest, "UTF8"); int index = content.indexOf(entryKey); if (index != -1) { StringTokenizer st = new StringTokenizer(content.substring(index + entryKey.length()), ";:\r\n"); return st.nextToken().trim(); return null; |
String | getManifestFileLocation(String moduleDir) get Manifest File Location String manifestLocation = new StringBuilder(moduleDir).append(File.separator).append(META_INF_DIR_NAME) .append(File.separator).append(MANIFEST_FILE_NAME).toString(); return manifestLocation; |
Properties | getManifestHeaders(File aJarFile) get Manifest Headers ZipFile zipFile = new ZipFile(aJarFile); Properties properties = new Properties(); try { ZipEntry zipEntry = zipFile.getEntry("META-INF/MANIFEST.MF"); InputStream is = zipFile.getInputStream(zipEntry); properties.load(is); is.close(); } catch (Throwable t) { ... |
Dictionary | getManifestHeaders(Manifest manifest) get Manifest Headers Hashtable<String, String> headers = new Hashtable<String, String>(); Attributes mainatts = manifest.getMainAttributes(); for (Object key : mainatts.keySet()) { String name = key.toString(); String value = mainatts.getValue(name); headers.put(name, value); return headers; ... |
List | getManifestHeaderValues(final Manifest manifest, final String headerName) get Manifest Header Values List<String> values = new ArrayList<>(); Attributes mainAttribs = manifest.getMainAttributes(); String valueList = mainAttribs.getValue(headerName); String[] valueArray = valueList != null ? valueList.split(",") : null; if (valueArray != null) { for (String value : valueArray) { if (!value.trim().isEmpty()) { values.add(value.trim()); ... |
String | getManifestPath(String moduleDir) get Manifest Path String manifestFileLocation = getManifestFileLocation(moduleDir); File manifestFile = new File(manifestFileLocation); if (!manifestFile.exists()) { throw new RuntimeException("The specified Manifest file doesn't exist: " + manifestFileLocation); return manifestFileLocation; |
String | getManifestProperty(ClassLoader clContainingManifest, String manifestKey) get Manifest Property InputStream is = clContainingManifest.getResourceAsStream("META-INF/MANIFEST.MF"); return readManifestProperty(is, manifestKey); |
String | getManifestProperty(File file, String name) get Manifest Property try (JarFile jarFile = new JarFile(file)) { Manifest manifest = jarFile.getManifest(); Attributes attributes = manifest.getMainAttributes(); return attributes.getValue(name); |
String | getManifestProperty(Manifest manifest, String propertyName) get Manifest Property Map<Object, Object> entries = manifest.getMainAttributes(); for (Iterator<Object> it = entries.keySet().iterator(); it.hasNext();) { Attributes.Name key = (Attributes.Name) it.next(); String keyName = key.toString(); if (propertyName.equals(keyName)) { return (String) entries.get(key); return null; |
String | getManifestValue(File jarFile, String key) Gets main attribute value from jar manifest JarFile jF = null; try { jF = new JarFile(jarFile); Manifest mf = jF.getManifest(); return mf.getMainAttributes().getValue(key); } finally { if (jF != null) { jF.close(); ... |