Class FileUtil


  • public final class FileUtil
    extends Object
    • Method Detail

      • read

        public static String read​(URL url)
      • copy

        public static void copy​(InputStream in,
                                OutputStream out)
                         throws IOException
        Copie le contenu d'un flux d'entrée vers un flux de sortie.
        Parameters:
        in - flux d'entrée
        out - flux de sortie
        Throws:
        IOException - Erreur d'entrée/sortie
      • copy

        public static void copy​(InputStream in,
                                File file)
                         throws IOException
        Copie le contenu d'un flux d'entrée vers un fichier de sortie.
        Parameters:
        in - flux d'entrée
        file - fichier de sortie
        Throws:
        IOException - Erreur d'entrée/sortie
      • getFileExtension

        public static String getFileExtension​(String fileName)
        Donne l'extension du fichier.

        This method returns the textual part of the filename after the last dot. There must be no directory separator after the dot.

         foo.txt      --> "txt"
         a/b/c.jpg    --> "jpg"
         a/b.txt/c    --> ""
         a/b/c        --> ""
         

        The output will be the same irrespective of the machine that the code is running on.

        Parameters:
        fileName - Nom du fichier
        Returns:
        the extension of the file or an empty string if none exists. (author Apache Commons IO 1.1)
      • translatePath

        public static String translatePath​(String path)
        Replace "user.home" "user.dir" and "java.io.tmpdir" by system value.
        Parameters:
        path - PAth to translate
        Returns:
        translated path
      • checkUserPath

        public static void checkUserPath​(String userPath)
        Check a filePath send by a user.
        Parameters:
        userPath - Path to check
      • checkUserFileName

        public static void checkUserFileName​(String userFileName)
        Check a filename send by a user.
        Parameters:
        userFileName - FileName to check