Package rife.bld.extension.tools
Class IOTools
java.lang.Object
rife.bld.extension.tools.IOTools
I/O Tools.
Utility methods for common file system operations including existence checks,
executability checks, directory creation, and path resolution. All methods
accept null inputs and return false (or an appropriate default)
rather than throwing NullPointerException.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanExecute(File file) Determines if the specified file exists, is a file, and is executable.static booleancanExecute(String path) Determines if the file at the specified path string exists, is a regular file, and is executable.static booleancanExecute(Path path) Determines if the specified path exists, is a regular file, and is executable.static booleanChecks if the specified file exists.static booleanChecks whether a file or directory exists at the specified path.static booleanChecks if the specified path exists.static booleanisDirectory(File file) Determines if the specifiedFileis a directory.static booleanisDirectory(String path) Determines if the specified path string represents an existing directory.static booleanisDirectory(Path path) Determines if the specifiedPathrepresents an existing directory.static booleanCreates the directory named by the specifiedFile, including any necessary but nonexistent parent directories.static booleanCreates the directory specified by the given path string, including any nonexistent parent directories as necessary.static booleanCreates the directory specified by the givenPath, including any nonexistent parent directories as necessary.static booleanChecks if the specified file does not exist.static booleanChecks whether a file or directory does not exist at the specified path.static booleanChecks if the specified path does not exist.static FileresolveFile(File base, String... segments) Resolves a file path by joining a base file with additional path segments.
-
Method Details
-
canExecute
Determines if the specified file exists, is a file, and is executable.- Parameters:
file- the file to be checked- Returns:
trueif the file exists, is a file, and can be executed;falseotherwise- Since:
- 1.0
-
canExecute
Determines if the specified path exists, is a regular file, and is executable.- Parameters:
path- the path to be checked- Returns:
trueif the path exists, is a regular file, and can be executed;falseotherwise- Since:
- 1.0
-
canExecute
Determines if the file at the specified path string exists, is a regular file, and is executable.- Parameters:
path- the path string to be checked- Returns:
trueif the path exists, is a regular file, and can be executed;falseotherwise- Since:
- 1.0
-
exists
Checks if the specified file exists.- Parameters:
file- the file to check for existence- Returns:
trueif the file is notnulland exists;falseotherwise- Since:
- 1.0
-
exists
Checks if the specified path exists.- Parameters:
path- the path to check for existence- Returns:
trueif the path is notnulland exists;falseotherwise- Since:
- 1.0
-
exists
Checks whether a file or directory exists at the specified path.- Parameters:
path- the file system path to check for existence- Returns:
trueif the path is notnulland a file or directory exists at the specified path;falseotherwise- Since:
- 1.0
-
isDirectory
Determines if the specifiedFileis a directory.- Parameters:
file- theFileobject to be checked; ifnull, returnsfalse- Returns:
trueif the file exists and is a directory;falseotherwise- Since:
- 1.0
-
isDirectory
Determines if the specifiedPathrepresents an existing directory.- Parameters:
path- thePathobject to be checked; ifnull, returnsfalse- Returns:
trueif the path exists and is a directory;falseotherwise- Since:
- 1.0
-
isDirectory
Determines if the specified path string represents an existing directory.- Parameters:
path- the path string to be checked; ifnullor blank, returnsfalse- Returns:
trueif the specified path exists and is a directory;falseotherwise (including when the path string is invalid)- Since:
- 1.0
-
mkdirs
Creates the directory named by the specifiedFile, including any necessary but nonexistent parent directories.Delegates to
mkdirs(Path)for consistent, race-condition-free behavior.- Parameters:
file- theFileobject representing the directory to be created; ifnull, this method returnsfalse- Returns:
trueif the directory was created successfully or already exists;falseif the directory could not be created orfileisnull- Since:
- 1.0
-
mkdirs
Creates the directory specified by the givenPath, including any nonexistent parent directories as necessary.- Parameters:
path- thePathobject representing the directory to be created; ifnull, this method returnsfalse- Returns:
trueif the directory was created successfully or already exists;falseif the directory could not be created orpathisnull- Since:
- 1.0
-
mkdirs
Creates the directory specified by the given path string, including any nonexistent parent directories as necessary.- Parameters:
path- the path string representing the directory to be created; ifnullor blank, this method returnsfalse- Returns:
trueif the directory was created successfully or already exists;falseif the directory could not be created orpathisnullor blank- Since:
- 1.0
-
notExists
Checks if the specified file does not exist.- Parameters:
file- the file to check for non-existence- Returns:
trueif the file isnullor does not exist;falseotherwise- Since:
- 1.0
-
notExists
Checks if the specified path does not exist.- Parameters:
path- the path to check for non-existence- Returns:
trueif the path isnullor does not exist;falseotherwise- Since:
- 1.0
-
notExists
Checks whether a file or directory does not exist at the specified path.- Parameters:
path- the file system path to check for non-existence- Returns:
trueif the path isnullor no file or directory exists at the specified path;falseotherwise- Since:
- 1.0
-
resolveFile
Resolves a file path by joining a base file with additional path segments.This method constructs a file path by appending one or more path segments to a base file.
nullsegments are silently skipped. The resultingFileobject represents the complete path but does not create an actual file on the filesystem.- Parameters:
base- the base file path to start from; may benullsegments- additional path segments to append, in order; may benull, and individualnullsegments are silently skipped- Returns:
- a
Filerepresenting the resolved path - Since:
- 1.0
-