Class FileUtil

    • Constructor Summary

      Constructors 
      Constructor Description
      FileUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean cleanDirectory​(java.io.File path)
      Delete recursively the content of a directory.
      static boolean copy​(java.io.File source, java.io.File destination)
      Simple copy of a source file to a destination file
      static boolean copyDirectory​(java.io.File source, java.io.File destination)
      Copying recursively a directory to another.
      static boolean deleteDirectory​(java.io.File path)
      Delete recursively a directory and its content.
      static java.util.List<java.io.File> list​(java.io.File dir, java.io.FileFilter filter, boolean recurse)
      List a directory and select files that are selected by the given file filter
      static java.util.List<java.io.File> list​(java.io.File source, java.lang.String regex, boolean recurse)
      List recursively a directory and select files that match the given regular expression.
      static java.util.List<java.lang.String> listPathes​(java.io.File dir, java.io.FileFilter filter, boolean recurse)
      List a directory and select files that are selected by the given file filter
      static long size​(java.io.File path)
      Return the file or directory size in byte
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FileUtil

        public FileUtil()
    • Method Detail

      • size

        public static long size​(java.io.File path)
        Return the file or directory size in byte
        Parameters:
        path - the file or directory to check
        Returns:
        the complete size in bytes of the file or directory.
      • deleteDirectory

        public static boolean deleteDirectory​(java.io.File path)
        Delete recursively a directory and its content. After cleaning all the contents, the directory itself is deleted.
        Parameters:
        path - path to the directory (or file) you want to delete
        Returns:
        true if the delete was successfull and false if the delete was unable to erase all the directory.
        See Also:
        cleanDirectory(File)
      • cleanDirectory

        public static boolean cleanDirectory​(java.io.File path)
        Delete recursively the content of a directory. Only the directory content is deleted, the directory itself is not deleted.
        Parameters:
        path - path to the directory (or file) you want to clean
        Returns:
        true if the delete was successfull and false if the delete was unable to erase all the directory
        See Also:
        deleteDirectory(File)
      • copy

        public static boolean copy​(java.io.File source,
                                   java.io.File destination)
        Simple copy of a source file to a destination file
        Parameters:
        source - the path of the source file
        destination - the path of the destination file
        Returns:
        true if the copy was successfull and false if not
      • copyDirectory

        public static boolean copyDirectory​(java.io.File source,
                                            java.io.File destination)
        Copying recursively a directory to another. If the destination directory does not exist, it is created.
        Parameters:
        source - the source directory (or file to copy)
        destination - the destination directory.
        Returns:
        true if the copy was successfull, false if the copy was unsuccessfull
      • list

        public static java.util.List<java.io.File> list​(java.io.File dir,
                                                        java.io.FileFilter filter,
                                                        boolean recurse)
        List a directory and select files that are selected by the given file filter
        Parameters:
        dir - the directory to list.
        filter - the file filter that accept or not listed files.
        recurse - is set to true if the listing process have to enter subdirectory, false otherwise.
        Returns:
        the files that are selected by the given file filter
      • listPathes

        public static java.util.List<java.lang.String> listPathes​(java.io.File dir,
                                                                  java.io.FileFilter filter,
                                                                  boolean recurse)
        List a directory and select files that are selected by the given file filter
        Parameters:
        dir - the directory to list.
        filter - the file filter that accept or not listed files.
        recurse - is set to true if the listing process have to enter subdirectory, false otherwise.
        Returns:
        the pathes of the files that are selected by the given file filter
      • list

        public static java.util.List<java.io.File> list​(java.io.File source,
                                                        java.lang.String regex,
                                                        boolean recurse)
        List recursively a directory and select files that match the given regular expression.
        Parameters:
        source - the directory to list.
        regex - the regular expression that the tested file path have to match.
        recurse - is set to true if the listing process have to enter subdirectory, false otherwise.
        Returns:
        the list of files contained within the given directory and from witch path are matched by te given regular expression.