0
点赞
收藏
分享

微信扫一扫

java 7中可以判断文件的contenttype了

兵部尚输 2022-12-05 阅读 85


java 7中可以判断文件的contenttype了,例子如下:

Path path = Paths.get("D:/Downloads/java.txt");

String contentType = null;

try {

contentType = Files.probeContentType(path);

} catch (IOException e) {



e.printStackTrace();

}

System.out.println("File content type is : " + contentType);



}


就是使用Files.probeContentType方法了.


举报

相关推荐

0 条评论