The manifest.mf contained in many Java jars contains headers which look much like email headers. See example [*]
I want something that can parse this format into key
MANIFEST.MF files can be read with the Manifest class:
Manifest manifest = new Manifest(new FileInputStream(new File("MANIFEST.MF")));
Then you can get all entries by doing
Map<String, Attributes> entries = manifest.getEntries();
And all main attributes by doing
Attributes attr = manifest.getMainAttributes();
My MANIFEST.MF
file is this:
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
My code:
Manifest manifest = new Manifest(new FileInputStream(new File("MANIFEST.MF")));
Attributes attr = manifest.getMainAttributes();
System.out.println(attr.getValue("Manifest-Version"));
System.out.println(attr.getValue("X-COMMENT"));
Output:
1.0
Main-Class will be added automatically by build