Apache tika detects mime-type incorrectly for csv

不羁的心 提交于 2019-12-01 11:43:27

问题


I've created .csv file using excel and I wrote following code using apache tika:

public static boolean checkThatMimeTypeIsCsv(InputStream inputStream) throws IOException {
    BufferedInputStream bis = new BufferedInputStream(inputStream);
    AutoDetectParser parser = new AutoDetectParser();
    Detector detector = parser.getDetector();
    Metadata md = new Metadata();
    MediaType mediaType = detector.detect(bis, md);
    return "text/csv".equals(mediaType.toString());
}

public static void main(String[] args) throws IOException {
    System.out.println(checkThatMimeTypeIsCsv(new FileInputStream("Data.csv")));
}

But it returns false'.

Does Tika so bad or I missed something?

来源:https://stackoverflow.com/questions/46960231/apache-tika-detects-mime-type-incorrectly-for-csv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!