package java7exemples; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class ContenuFichiers { public static void main(String[] args) throws Exception { displayContentType("c:/test.txt"); // text/plain displayContentType("c:/lders.dll"); // application/x-msdownload displayContentType("c:/test.doc"); // application/msword displayContentType("c:/java.gif"); // image/gif } // Afficher le type de contenu de fichier passé en paramètre static void displayContentType(String pathText) throws Exception { Path path = Paths.get(pathText); String type = Files.probeContentType(path); System.out.println(type); } } |
----------------------------------------------------------------------------
A Voir sur le même Sujet:
- java - déterminer le type d'un fichier
- déterminer type de fichier java
- Files.probeContentType(path) JAVA WIKIPEDIA
- zone de texte pour afficher le contenu d'un fichier java
- java déterminer type de fichier
- DES et cryptage de fichier gif+ JAVA
- Lister des fichiers par extension contenu dans un repertoire en java
- savoir le type de contenu de String + java
- telecharger determiner le type de fichier
- déterminer le nombre fichier d'un type dans répertoire java