Identifying file type in Java

前端 未结 6 1175
盖世英雄少女心
盖世英雄少女心 2020-12-08 23:24

Please help me to find out the type of the file which is being uploaded. I wanted to distinguish between excel type and csv.

MIMEType returns same for both of thes

6条回答
  •  感动是毒
    2020-12-08 23:39

    A better way without using javax.activation.*:

     URLConnection.guessContentTypeFromName(f.getAbsolutePath()));
    

提交回复
热议问题