Getting A File's Mime Type In Java

后端 未结 23 2721
南方客
南方客 2020-11-21 06:53

I was just wondering how most people fetch a mime type from a file in Java? So far I\'ve tried two utils: JMimeMagic & Mime-Util.

Th

23条回答
  •  情深已故
    2020-11-21 07:22

    Apache Tika.

    
    
        org.apache.tika
        tika-parsers
        1.24
    
    
    

    and Two line of code.

    Tika tika=new Tika();
    tika.detect(inputStream);
    

    Screenshot below

提交回复
热议问题