Java Code Examples for org.apache.tika.mime.MediaType#EMPTY

The following examples show how to use org.apache.tika.mime.MediaType#EMPTY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DirectoryScanner.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
private MediaType getMediaType(Path file) {
    try (InputStream stream = TikaInputStream.get(file)) {
        Metadata metadata = new Metadata();
        metadata.set(Metadata.RESOURCE_NAME_KEY, file.toString());
        return tikaConfig.getDetector().detect(stream, metadata);
    } catch (IOException e) {
        return MediaType.EMPTY;
    }
}
 
Example 2
Source File: DirectoryScanner.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
private MediaType getMediaType(InputStream stream) {
    try {
        return tikaConfig.getDetector().detect(TikaInputStream.get(stream), new Metadata());
    } catch (IOException e) {
        return MediaType.EMPTY;
    }
}