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

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方法了.

你可能感兴趣的:(JAVA相关)