Is there any java library that is similar to unix's command file
?
ie:
$ file somepicture.png somepicture.png PNG image, 805 x 292, 8-bit/color RGB, non-interlaced
The file command is such a nice tool. I need something that can tell me if the file is really what I want it to be. (ie a picture, document etc)
I know I can run the command file
, but I am looking for a java library, not running the actual unix command.
A quick google search (for the admittedly non-obvious) "java magic file detection" brings up a fairly nice looking article, "Get the Mime Type from a File" which suggests you use one of the following:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With