if (document.isEmpty()) {
throw new IllegalArgumentException("No input document URL specified");
}
final DocumentSource documentSource = document.get(0);
final MIMETypeDetector detector = new TikaMIMETypeDetector();
final MIMEType mimeType = detector.guessMIMEType(
documentSource.getDocumentURI(),
documentSource.openInputStream(),
MIMEType.parse(documentSource.getContentType())
);
System.out.println(mimeType);