Results 1 to 4 of 4
  1. #1
    hopcroft is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default 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

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default 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.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,391
    Rep Power
    25

    Default Re: How do I get the file type??

    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.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default 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...

Similar Threads

  1. Replies: 0
    Last Post: 10-31-2011, 11:13 PM
  2. Replies: 6
    Last Post: 02-10-2011, 09:55 AM
  3. retain value of input type file in a jsp file while being dynamically generated
    By nidhi c in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 02:21 AM
  4. Mime type of a file from web
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-03-2008, 05:20 PM
  5. Mime type of a file
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-03-2008, 05:18 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •