Java 7: Déterminer le type de contenu d’un fichier

Author:

 int,string,char,static, url, socket, url, socket, java
{filelink=23}


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:

  • déterminer le nombre fichier d'un type dans répertoire java
  • java - déterminer le type d'un fichier
  • java déterminer type de fichier
  • telecharger determiner le type de fichier
  • DES et cryptage de fichier gif+ JAVA
  • zone de texte pour afficher le contenu d'un fichier java
  • Files.probeContentType(path) JAVA WIKIPEDIA
  • Lister des fichiers par extension contenu dans un repertoire en java
  • méthode pour lister les fichiers texte d'un repertoire + java
  • déterminer type de fichier java

Leave a Reply

Your email address will not be published. Required fields are marked *