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 value pairs:
Map<String, String> manifest = <mystery-parse-function>(new File("manifest.mf"));
I have googled around a bit for "parse manifest.mf" "manifest.mf format" etc. and I find plenty of information about the meaning of the headers (e.g. in OSGI bundles, standard Java jars, etc.) but that's not what I'm looking for.
Looking at some example manifest.mf files I could probably implement something to parse it (reverse engineer the format) but I won't know if my implementation is actually correct. So I'm also not looking for someone else's quickly thrown together parse function as it suffers the same problem).
A good answer to my question could point me to a specification of the format (so I can write my own correct parse function). The best answer points me to an existing open-source library that already has a correct implementation.
MANIFEST.MF files can be read with the Manifest class:
Then you can get all entries by doing
And all main attributes by doing
A working example
My
MANIFEST.MF
file is this:My code:
Output: