Spec-Zone.ru › OpenJDK 25

Class FileTypeDetector

java.lang.Object
java.nio.file.spi.FileTypeDetector
public abstract class FileTypeDetector extends Object
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 or the bytes in a file may be examined to guess its file type.

Since:
1.7
See Also:
  • Files.probeContentType(Path)

Constructor Summary

FileTypeDetector()
Modifier Constructor Description
protected
Initializes a new instance of this class.

Method Summary

Modifier and Type Method Description
abstract String probeContentType(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, wait

Constructor Details

FileTypeDetector

protected FileTypeDetector()
Initializes a new instance of this class.

Method Details

probeContentType

public abstract String probeContentType(Path path) throws IOException
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 null if the file type is not recognized
Throws:
IOException - An I/O error occurs
External Specifications
  • RFC 2045: Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies
See Also:
  • Files.probeContentType(Path)

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2025, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/file/spi/FileTypeDetector.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API