Package com.ultikits.ultitools.utils
Class FileUtils
java.lang.Object
com.ultikits.ultitools.utils.FileUtils
File operation utility class.
Replaces hutool's FileUtil / FileNameUtil.
- Since:
- 6.2.0
- Author:
- wisdomme
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanDeletes a file or directory.static booleandeleteDirectory(File directory) Recursively deletes a directory.static StringGets the file extension.static StringGets the file extension.static StringGets the file's base name (without extension).static StringGets the file's base name (without extension).static FileEnsures the directory exists, creating it if not.static FilemkParentDirs(File file) Ensures the file's parent directory exists.static booleanCreates a file, automatically creating the parent directory if it does not exist.
-
Constructor Details
-
FileUtils
private FileUtils()
-
-
Method Details
-
touch
Creates a file, automatically creating the parent directory if it does not exist.- Parameters:
file- the file- Returns:
- whether creation succeeded
-
del
Deletes a file or directory.- Parameters:
file- the file or directory- Returns:
- whether deletion succeeded
-
deleteDirectory
Recursively deletes a directory.- Parameters:
directory- the directory- Returns:
- whether deletion succeeded
-
mainName
Gets the file's base name (without extension).- Parameters:
file- the file- Returns:
- the base file name
-
mainName
Gets the file's base name (without extension).- Parameters:
fileName- the file name- Returns:
- the base file name
-
extName
Gets the file extension.- Parameters:
file- the file- Returns:
- the extension (without the dot)
-
extName
Gets the file extension.- Parameters:
fileName- the file name- Returns:
- the extension (without the dot)
-
mkdir
Ensures the directory exists, creating it if not.- Parameters:
dir- the directory- Returns:
- the directory
-
mkParentDirs
Ensures the file's parent directory exists.- Parameters:
file- the file- Returns:
- the file
-