How to write a probeContentType() and Usage?

Files.probeContentType() is an instance of FileTypeDetector class's abstract method String FileTypeDetector.probeContentType(), it's an extension based detector. So extend it in a new class or even anonyinter class (cannot do that because FileTypeDetector is an abstract class) might work.

1 public class MyDetector extends java.nio.file.spi.FileTypeDetector{
2     public String probeContentType(Path path) throws IOException{
3         return SOMESTRING;
4     }
5 }
1 //Call the detector
2 String type = MyDetector.probeContentType(path);

 

posted on 2016-04-14 12:05  三叁  阅读(260)  评论(0编辑  收藏  举报

导航