Objective: given the file, determine whether it is of a given type (XML, JSON, Properties etc)
Consider the case of XML - Up until we ran into this issue, the follow
Apache Tika gives me the least amount of issues and is not platform specific unlike Java 7 : Files.probeContentType
import java.io.File;
import java.io.IOException;
import javax.activation.MimeType;
import org.apache.tika.Tika;
File inputFile = ...
String type = new Tika().detect(inputFile);
System.out.println(type);
For a xml file I got 'application/xml'
for a properties file I got 'text/plain'
You can however add a Detector to the new Tika()
org.apache.tika
tika-core
1.xx