java.lang.Object
org.jorigin.io.FileUtil
A file management API. This Class provide simple and efficient file management methods.
- Since:
- 1.0.0
- Version:
- "1.0.14" - b202111241200L
- Author:
- Julien SEINTURIER - Université de Toulon / CNRS LIS umr 7020 - github.com/jorigin/jcommon (contact@jorigin.org)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancleanDirectory(File path) Delete recursively the content of a directory.static booleanSimple copy of a source file to a destination filestatic booleancopyDirectory(File source, File destination) Copying recursively a directory to another.static booleandeleteDirectory(File path) Delete recursively a directory and its content.list(File dir, FileFilter filter, boolean recurse) List a directory and select files that are selected by the givenfile filterList recursively a directory and select files that match the given regular expression.listPathes(File dir, FileFilter filter, boolean recurse) List a directory and select files that are selected by the givenfile filterstatic longReturn the file or directory size in byte
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
size
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
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:
trueif the delete was successfull andfalseif the delete was unable to erase all the directory.- See Also:
-
cleanDirectory
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:
trueif the delete was successfull andfalseif the delete was unable to erase all the directory- See Also:
-
copy
Simple copy of a source file to a destination file- Parameters:
source- the path of the source filedestination- the path of the destination file- Returns:
trueif the copy was successfull andfalseif not
-
copyDirectory
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:
trueif the copy was successfull,falseif the copy was unsuccessfull
-
list
List a directory and select files that are selected by the givenfile filter- Parameters:
dir- the directory to list.filter- thefile filterthat accept or not listed files.recurse- is set totrueif the listing process have to enter subdirectory,falseotherwise.- Returns:
- the files that are selected by the given
file filter
-
listPathes
List a directory and select files that are selected by the givenfile filter- Parameters:
dir- the directory to list.filter- thefile filterthat accept or not listed files.recurse- is set totrueif the listing process have to enter subdirectory,falseotherwise.- Returns:
- the pathes of the files that are selected by the given
file filter
-
list
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 totrueif the listing process have to enter subdirectory,falseotherwise.- Returns:
- the list of files contained within the given directory and from witch path are matched by te given regular expression.
-