There are a few years since this question was asked before and previous answers such as,
How to reliably detect file types?
Shows some old libraries, of which most of them no longer seems to be maintained. So I figured this question deserves to be asked again.
What I would need is a good way to identify the type of a file based on content. Something like the file
command in Linux. In particular I am interesting in type detection for crypto files.
I file may called client.crt, but the actual content uses the PEM format, so file extension is not really usable here. Further, for Linux, file extension is optional.
Apache TIKA seems to be developed still, but the size of it is about 75MB. Further, it seems to have a limited support for crypto files.
I understand this is a complicated thing to do and the file
command is a quite advanced tool. Anyone who knows how to deal with this in a good way?
BR Patrik
EDIT
Looks as if this question have gotten a close vote already. I am not really looking for a library which can do this. Code examples using the Java standard library is good enough, but this is too tedious to do from scratch (hence the absence of a code example). A good code example would be great, which makes it fit well on stack overflow.