I retrieve the content of a file via HTTP-request and let Tika guess which MIME type it is most likely, e.g.
byte[] myFileContent;
.....
String mime_type=new Tika().detect(myFileContent);
Then I store the content in the File system and calculate the M5-sum as unique file name (only several hundereds of files). Most likely the content is PDF.
String extension=".pdf";
File write=new File(MD5 + extension);
if (write.exists()) {....
....
}
Matter of fact is that I want to set the content more or less dynamically. Is there some way to retrieve the list automatically? Instead of using a handmade list for checking? Something like
extension=Tika.suggestFileExtension(myFileContent);