标签:
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);
How to write a probeContentType() and Usage?
标签:
原文地址:http://www.cnblogs.com/sansna/p/5390550.html