In a web project, users upload their files, but when I receive them on the server, they are being stored as .tmp files rather than their original file extension (this is my
Take a look at the Apache Tika. It can easily determine a mime type:
Tika tika = new Tika(); File file = ... String mimeType = tika.detect(file);
Here's a minimal required maven dependency:
org.apache.tika tika-core 1.12