java.nio.file.spi

Class 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 Detail

      • FileTypeDetector

        protected FileTypeDetector()
        Initializes a new instance of this class.
        Throws:
        SecurityException - If a security manager has been installed and it denies RuntimePermission("fileTypeDetector")
    • Method Detail

      • 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 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. 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
        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 SecurityManager.checkRead(String) method is invoked to check read access to the file.
        See Also:
        Files.probeContentType(java.nio.file.Path)

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Document créé le 11/06/2005, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/nio/file/spi/FileTypeDetector.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut