- java.lang.Object
-
- org.jorigin.io.FileUtil
-
public class FileUtil extends Object
A file management API. This Class provide simple and efficient file management methods.- Since:
- 1.0.0
- Version:
- "1.0.13" - b202005081200L
- Author:
- Julien Seinturier - COMEX S.A. - contact@jorigin.org - https://github.com/jorigin/jeometry
-
-
Constructor Summary
Constructors Constructor Description FileUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancleanDirectory(File path)Delete recursively the content of a directory.static booleancopy(File source, File destination)Simple 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.static List<File>list(File dir, FileFilter filter, boolean recurse)List a directory and select files that are selected by the givenfile filterstatic List<File>list(File source, String regex, boolean recurse)List recursively a directory and select files that match the given regular expression.static List<String>listPathes(File dir, FileFilter filter, boolean recurse)List a directory and select files that are selected by the givenfile filterstatic longsize(File path)Return the file or directory size in byte
-
-
-
Method Detail
-
size
public static long size(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(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:
trueif the delete was successfull andfalseif the delete was unable to erase all the directory.- See Also:
cleanDirectory(File)
-
cleanDirectory
public static boolean cleanDirectory(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:
trueif the delete was successfull andfalseif the delete was unable to erase all the directory- See Also:
deleteDirectory(File)
-
copy
public static boolean copy(File source, File destination)
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
public static boolean copyDirectory(File source, 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:
trueif the copy was successfull,falseif the copy was unsuccessfull
-
list
public static List<File> list(File dir, FileFilter filter, boolean recurse)
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
public static List<String> listPathes(File dir, FileFilter filter, boolean recurse)
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
public static List<File> list(File source, 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 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.
-
-