Package rife.tools
Class DirBuilder
java.lang.Object
rife.tools.DirBuilder
Directory and file structure builder, using a fluent API and lambdas
to convey the hierarchical structure of on the filesystem in code.
- Since:
- 1.5.19
- See Also:
-
Constructor Summary
ConstructorDescriptionDirBuilder
(File dir) Constructs a newDirBuilder
instance with the specified directory.DirBuilder
(File dir, DirAction action) Constructs a newDirBuilder
instance with the specified path and executes an action on it.DirBuilder
(Path path) Constructs a newDirBuilder
instance with the specified path.DirBuilder
(Path path, DirAction action) Constructs a newDirBuilder
instance with the specified directory and executes an action on it. -
Method Summary
Modifier and TypeMethodDescriptiondelete()
Deletes the directory represented by thisDirBuilder
and all of its contents.Creates a new subdirectory with the specified name under the directory represented by thisDirBuilder
.Creates a new subdirectory with the specified name under the directory represented by thisDirBuilder
and executes the specified action on it.file
(String file, FileAction action) Specify a new file under the directory represented by thisDirBuilder
and executes the specified action on it.perms
(int mode) Sets the permissions for the directory represented by thisDirBuilder
using the specified Posix mode.perms
(Set<PosixFilePermission> permissions) Sets the permissions for the directory represented by thisDirBuilder
using the specified permissions.
-
Constructor Details
-
DirBuilder
Constructs a newDirBuilder
instance with the specified directory.- Parameters:
dir
- The directory to use for this DirBuilder.- Since:
- 1.5.19
-
DirBuilder
Constructs a newDirBuilder
instance with the specified path.- Parameters:
path
- The path to use for this DirBuilder.- Since:
- 1.5.19
-
DirBuilder
Constructs a newDirBuilder
instance with the specified path and executes an action on it.- Parameters:
dir
- The directory to use for thisDirBuilder
.action
- The action to execute on the directory.- Throws:
IOException
- if an error occurs while executing the action.- Since:
- 1.5.19
-
DirBuilder
Constructs a newDirBuilder
instance with the specified directory and executes an action on it.- Parameters:
path
- The path to use for this DirBuilder.action
- The action to execute on the directory.- Throws:
IOException
- if an error occurs while executing the action.- Since:
- 1.5.19
-
-
Method Details
-
dir
Creates a new subdirectory with the specified name under the directory represented by thisDirBuilder
.- Parameters:
dir
- The name of the subdirectory to create.- Returns:
- this
DirBuilder
instance. - Throws:
IOException
- if an error occurs while creating the subdirectory.- Since:
- 1.5.19
-
dir
Creates a new subdirectory with the specified name under the directory represented by thisDirBuilder
and executes the specified action on it.- Parameters:
dir
- The name of the subdirectory to create.action
- The action to execute on the subdirectory.- Returns:
- this
DirBuilder
instance. - Throws:
IOException
- if an error occurs while creating the subdirectory or executing the action.- Since:
- 1.5.19
-
file
Specify a new file under the directory represented by thisDirBuilder
and executes the specified action on it.- Parameters:
file
- The name of the file to create.action
- The action to execute on the file.- Returns:
- this
DirBuilder
instance. - Throws:
IOException
- if an error occurs while creating the file or executing the action.- Since:
- 1.5.19
-
delete
Deletes the directory represented by thisDirBuilder
and all of its contents.- Returns:
- this
DirBuilder
instance. - Throws:
IOException
- if an error occurs while deleting the directory.- Since:
- 1.5.19
-
perms
Sets the permissions for the directory represented by thisDirBuilder
using the specified Posix mode.- Parameters:
mode
- The mode to use for setting the permissions.- Returns:
- this
DirBuilder
instance. - Throws:
IOException
- if an error occurs while setting the permissions.- Since:
- 1.5.19
-
perms
Sets the permissions for the directory represented by thisDirBuilder
using the specified permissions.- Parameters:
permissions
- The permissions to use for setting the permissions.- Returns:
- this
DirBuilder
instance. - Throws:
IOException
- if an error occurs while setting the permissions.- Since:
- 1.5.19
-