Class FileUtil

java.lang.Object
io.vertigo.core.util.FileUtil

public final class FileUtil extends Object
  • Method Details

    • doOnFile

      public static <R> R doOnFile(URL url, Function<Path,R> fileProcessor)
    • read

      public static String read(URL url)
    • getFileSize

      public static long getFileSize(URL url)
    • 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
    • sanitizeFileName

      public static String sanitizeFileName(String fileName)