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
ConstructorsConstructorDescriptionDirBuilder(File dir) Constructs a newDirBuilderinstance with the specified directory.DirBuilder(File dir, DirAction action) Constructs a newDirBuilderinstance with the specified path and executes an action on it.DirBuilder(Path path) Constructs a newDirBuilderinstance with the specified path.DirBuilder(Path path, DirAction action) Constructs a newDirBuilderinstance with the specified directory and executes an action on it. -
Method Summary
Modifier and TypeMethodDescriptiondelete()Deletes the directory represented by thisDirBuilderand 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 thisDirBuilderand executes the specified action on it.file(String file, FileAction action) Specify a new file under the directory represented by thisDirBuilderand executes the specified action on it.perms(int mode) Sets the permissions for the directory represented by thisDirBuilderusing the specified Posix mode.perms(Set<PosixFilePermission> permissions) Sets the permissions for the directory represented by thisDirBuilderusing the specified permissions.
-
Constructor Details
-
DirBuilder
Constructs a newDirBuilderinstance with the specified directory.- Parameters:
dir- The directory to use for this DirBuilder.- Since:
- 1.5.19
-
DirBuilder
Constructs a newDirBuilderinstance with the specified path.- Parameters:
path- The path to use for this DirBuilder.- Since:
- 1.5.19
-
DirBuilder
Constructs a newDirBuilderinstance 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 newDirBuilderinstance 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
DirBuilderinstance. - 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 thisDirBuilderand 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
DirBuilderinstance. - 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 thisDirBuilderand 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
DirBuilderinstance. - Throws:
IOException- if an error occurs while creating the file or executing the action.- Since:
- 1.5.19
-
delete
Deletes the directory represented by thisDirBuilderand all of its contents.- Returns:
- this
DirBuilderinstance. - Throws:
IOException- if an error occurs while deleting the directory.- Since:
- 1.5.19
-
perms
Sets the permissions for the directory represented by thisDirBuilderusing the specified Posix mode.- Parameters:
mode- The mode to use for setting the permissions.- Returns:
- this
DirBuilderinstance. - Throws:
IOException- if an error occurs while setting the permissions.- Since:
- 1.5.19
-
perms
Sets the permissions for the directory represented by thisDirBuilderusing the specified permissions.- Parameters:
permissions- The permissions to use for setting the permissions.- Returns:
- this
DirBuilderinstance. - Throws:
IOException- if an error occurs while setting the permissions.- Since:
- 1.5.19
-