Package com.norconex.importer.doc
Class ContentTypeDetector
- java.lang.Object
-
- com.norconex.importer.doc.ContentTypeDetector
-
public final class ContentTypeDetector extends Object
Master class to detect all content types. This class is thread-safe.- Since:
- 2.0.0
- Author:
- Pascal Essiembre
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ContentType
detect(File file)
Detects the content type of the given file.static ContentType
detect(File file, String fileName)
Detects the content type of the given file.static ContentType
detect(InputStream content)
Detects the content type from the given input stream.static ContentType
detect(InputStream content, String fileName)
Detects the content type from the given input stream.
-
-
-
Method Detail
-
detect
public static ContentType detect(File file) throws IOException
Detects the content type of the given file.- Parameters:
file
- file on which to detect content type- Returns:
- the detected content type
- Throws:
IOException
- problem detecting content type
-
detect
public static ContentType detect(File file, String fileName) throws IOException
Detects the content type of the given file.- Parameters:
file
- file on which to detect content typefileName
- a file name which can help influence detection- Returns:
- the detected content type
- Throws:
IOException
- problem detecting content type
-
detect
public static ContentType detect(InputStream content) throws IOException
Detects the content type from the given input stream.- Parameters:
content
- the content on which to detect content type- Returns:
- the detected content type
- Throws:
IOException
- problem detecting content type
-
detect
public static ContentType detect(InputStream content, String fileName) throws IOException
Detects the content type from the given input stream.- Parameters:
content
- the content on which to detect content typefileName
- a file name which can help influence detection- Returns:
- the detected content type
- Throws:
IOException
- problem detecting content type
-
-