Class FileTypeDetector
A file type detector is a concrete implementation of this class, has a zero-argument constructor, and implements the abstract methods specified below.
The means by which a file type detector determines the file type is highly implementation specific. A simple implementation might examine the file extension (a convention used in some platforms) and map it to a file type. In other cases, the file type may be stored as a file attribute or the bytes in a file may be examined to guess its file type.
- Since:
- 1.7
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitializes a new instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionabstract StringprobeContentType(Path path) Probes the given file to guess its content type.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Creates and returns a copy of this object.booleanIndicates whether some other object is "equal to" this one.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class<?> getClass()Returns the runtime class of thisObject.inthashCode()Returns a hash code value for this object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final voidwait(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final voidwait(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
FileTypeDetector
protected FileTypeDetector()Initializes a new instance of this class.
-
-
Method Details
-
probeContentType
Probes the given file to guess its content type.The means by which this method determines the file type is highly implementation specific. It may simply examine the file name, it may use a file attribute, or it may examine bytes in the file.
The probe result is the string form of the value of a Multipurpose Internet Mail Extension (MIME) content type as defined by RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies. The string must be parsable according to the grammar in the RFC 2045.
- Parameters:
path- the path to the file to probe- Returns:
- The content type or
nullif the file type is not recognized - Throws:
IOException- An I/O error occurs- External Specifications
- See Also:
-