I am trying to get the mime type of a file without extension using :
File file = new File("C:\\Users\\user\\Desktop\\a.txt");
File file1 = new File("C:\\Users\\user\\Desktop\\folder\\a");
MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
// only by file name
String mimeType = mimeTypesMap.getContentType(file1);
The mime type of file a.txt
is text/plain which is correct,
But the mime type of file1 is application/octet-stream.
although they are the same file but one with and the other without extension, so what is the best and the correct way to get the mime types of files without extension?
I used a third party tool like Tika, but I don't want to use it since it is making a lot of conflict on my app.