java.nio.file.spi.FileTypeDetector Class extends java.lang.Object Class. FileTypeDetector Class contain method to know about the content type of given file.
public abstract class FileTypeDetector extends Object
Constructor Description protected FileTypeDetector() It is used the creation of a new object of FileTypeDetector class.
Method Description probeContentType(Path path) It is used to guess the content type of the given file.
abstract String probeContentType(Path path): It is used to guess the content type of the given file. To know the content type of the file this method may examine the filename, use file attribute, or even examine the bytes in the file. The way of examination of file solely depends on the implementation.
- path – the path of the file whose content type is to be guessed
Returns: The content type of the given file.If the file type is not recognized it returns null.
- IOException – if an I/O error occurs
- SecurityException – If the security manager denies access to the given file.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.