How do I get the file type??
Hi,
I'm trying to get the type of a specified file. But I don't want to obtain it from the file extension.
Instead of that I have used the file command in unix:
file --mime-type myfile.myExtension
Then I execute this command from my java class using the exec() method. Everything works fine. The main problem is that I need the file command within my OS. If I run my java code in a Windows machine it doesn't work. So, I'm just wondering if someone knows how to get the file type in a different way?.
Regards,
hopcroft
Re: How do I get the file type??
A Java version?
A quick google and JMimeMagic and Apache Tika are mentioned.
I have no idea of the quality (or usefuleness) of either of these, but I will say JMimeMagic appears to be at 0.1 and Tika appears to be at 1.0.
Re: How do I get the file type??
Quote:
my java code in a Windows machine it doesn't work.
What would you want as a file type on a Windows machine? Windows uses the files's extension to control what programs are used to open a file.
Re: How do I get the file type??
Of course, the OP has got an answer (similar to mine) over at OTN.
Nice of them to tell us they'd cross-posted...