Package org.apache.tika.mime
Class MimeTypesFactory
java.lang.Object
org.apache.tika.mime.MimeTypesFactory
Creates instances of MimeTypes.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
System property to set a path to an additional external custom mimetypes XML file to be loaded. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic MimeTypes
create()
Creates an empty instance; same as calling new MimeTypes().static MimeTypes
create
(InputStream stream) static MimeTypes
create
(InputStream... inputStreams) Creates and returns a MimeTypes instance from the specified input stream.static MimeTypes
Creates and returns a MimeTypes instance from the specified file path, as interpreted by the class loader in getResource().static MimeTypes
Creates and returns a MimeTypes instance.static MimeTypes
create
(String coreFilePath, String extensionFilePath, ClassLoader classLoader) Creates and returns a MimeTypes instance.static MimeTypes
static MimeTypes
Creates and returns a MimeTypes instance from the resource at the location specified by the URL.static MimeTypes
Creates and returns a MimeTypes instance from the specified document.
-
Field Details
-
CUSTOM_MIMES_SYS_PROP
System property to set a path to an additional external custom mimetypes XML file to be loaded.- See Also:
-
-
Constructor Details
-
MimeTypesFactory
public MimeTypesFactory()
-
-
Method Details
-
create
Creates an empty instance; same as calling new MimeTypes().- Returns:
- an empty instance
-
create
Creates and returns a MimeTypes instance from the specified document.- Throws:
MimeTypeException
- if the type configuration is invalid
-
create
Creates and returns a MimeTypes instance from the specified input stream. Does not close the input stream(s).- Throws:
IOException
- if the stream can not be readMimeTypeException
- if the type configuration is invalid
-
create
- Throws:
IOException
MimeTypeException
- See Also:
-
create
Creates and returns a MimeTypes instance from the resource at the location specified by the URL. Opens and closes the InputStream from the URL. If multiple URLs are supplied, then they are loaded in turn.- Throws:
IOException
- if the URL can not be accessedMimeTypeException
- if the type configuration is invalid
-
create
- Throws:
IOException
MimeTypeException
- See Also:
-
create
Creates and returns a MimeTypes instance from the specified file path, as interpreted by the class loader in getResource().- Throws:
IOException
- if the file can not be accessedMimeTypeException
- if the type configuration is invalid
-
create
public static MimeTypes create(String coreFilePath, String extensionFilePath) throws IOException, MimeTypeException Creates and returns a MimeTypes instance. The core mimetypes will be loaded from the specified file path, and any custom override mimetypes found will loaded afterwards. The file paths will be interpreted by the default class loader in getResource().- Parameters:
coreFilePath
- The main MimeTypes file to loadextensionFilePath
- The name of extension MimeType files to load afterwards- Throws:
IOException
- if the file can not be accessedMimeTypeException
- if the type configuration is invalid
-
create
public static MimeTypes create(String coreFilePath, String extensionFilePath, ClassLoader classLoader) throws IOException, MimeTypeException Creates and returns a MimeTypes instance. The core mimetypes will be loaded from the specified file path, and any custom override mimetypes found will loaded afterwards. The file paths will be interpreted by the specified class loader in getResource(). It will also load custom mimetypes from the system propertyCUSTOM_MIMES_SYS_PROP
, if specified.- Parameters:
coreFilePath
- The main MimeTypes file to loadextensionFilePath
- The name of extension MimeType files to load afterwards- Throws:
IOException
- if the file can not be accessedMimeTypeException
- if the type configuration is invalid
-