Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Protected Ctors](https://developer.android.com/reference/java/nio/file/spi/FileTypeDetector#proctors) \| [Methods](https://developer.android.com/reference/java/nio/file/spi/FileTypeDetector#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/nio/file/spi/FileTypeDetector#inhmethods)

# FileTypeDetector

` public abstract class FileTypeDetector `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.nio.file.spi.FileTypeDetector |

<br />

*** ** * ** ***

A file type detector for probing a file to guess its file type.

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](https://developer.android.com/reference/java/nio/file/attribute/package-summary.html) or the bytes in a file may be examined to guess its file type.
**See also:**

- `https://developer.android.com/reference/java/nio/file/Files#probeContentType(java.nio.file.Path)`

## Summary

| ### Protected constructors ||
|---|---|
| ` https://developer.android.com/reference/java/nio/file/spi/FileTypeDetector#FileTypeDetector()() ` Initializes a new instance of this class. |

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/nio/file/spi/FileTypeDetector#probeContentType(java.nio.file.Path)(https://developer.android.com/reference/java/nio/file/Path path) ` Probes the given file to guess its content type. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(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.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(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 void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Protected constructors

### FileTypeDetector

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected FileTypeDetector ()
```

Initializes a new instance of this class.

<br />

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/SecurityException` | If a security manager has been installed and it denies `https://developer.android.com/reference/java/lang/RuntimePermission``("fileTypeDetector")` |

## Public methods

### probeContentType

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String probeContentType (Path path)
```

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](https://developer.android.com/reference/java/nio/file/attribute/package-summary.html), or it may examines 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*](http://www.ietf.org/rfc/rfc2045.txt). The string must be parsable according to the grammar in the RFC 2045.

<br />

| Parameters ||
|---|---|
| `path` | `Path`: the path to the file to probe <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | The content type or `null` if the file type is not recognized <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/io/IOException` | An I/O error occurs |
| `https://developer.android.com/reference/java/lang/SecurityException` | If the implementation requires to access the file, and a security manager is installed, and it denies an unspecified permission required by a file system provider implementation. If the file reference is associated with the default file system provider then the `https://developer.android.com/reference/java/lang/SecurityManager#checkRead(java.lang.String)` method is invoked to check read access to the file. |

**See also:**

- `https://developer.android.com/reference/java/nio/file/Files#probeContentType(java.nio.file.Path)`