Package rife.tools
Class FileBuilder
java.lang.Object
rife.tools.FileBuilder
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
ConstructorDescriptionFileBuilder
(File file) Constructs a newFileBuilder
object with the specified file.FileBuilder
(File file, FileAction action) Constructs a newFileBuilder
object with the specified file and performs an action on it.FileBuilder
(Path path) Constructs a newFileBuilder
object with the specified path.FileBuilder
(Path path, FileAction action) Constructs a newFileBuilder
object with the specified path and performs an action on it. -
Method Summary
Modifier and TypeMethodDescriptionCopies the specified source file to the file of thisFileBuilder
.delete()
Deletes the file object of thisFileBuilder
.Moves the specified source file to the file of thisFileBuilder
.perms
(int mode) Sets the permissions for the file represented by thisFileBuilder
using the specified Posix mode.perms
(Set<PosixFilePermission> permissions) Sets the permissions for the file represented by thisFileBuilder
using the specified permissions.touch()
Touches the file of thisFileBuilder
.Writes the specified text to the file of thisFileBuilder
.
-
Constructor Details
-
FileBuilder
Constructs a newFileBuilder
object with the specified file.- Parameters:
file
- The file object to perform operations on- Since:
- 1.5.19
-
FileBuilder
Constructs a newFileBuilder
object with the specified path.- Parameters:
path
- The path to perform operations on- Since:
- 1.5.19
-
FileBuilder
Constructs a newFileBuilder
object with the specified file and performs an action on it.- Parameters:
file
- The file object to perform operations onaction
- The action to be performed on the file object- Throws:
IOException
- if an error occurs while executing the action.- Since:
- 1.5.19
-
FileBuilder
Constructs a newFileBuilder
object with the specified path and performs an action on it.- Parameters:
path
- The path to perform operations onaction
- The action to be performed on the file object- Throws:
IOException
- if an error occurs while executing the action.- Since:
- 1.5.19
-
-
Method Details
-
copy
Copies the specified source file to the file of thisFileBuilder
.- Parameters:
source
- The source file to be copied- Returns:
- this
FileBuilder
object - Throws:
IOException
- if an error occurs while copying the file.- Since:
- 1.5.19
-
move
Moves the specified source file to the file of thisFileBuilder
.- Parameters:
source
- The source file to be moved- Returns:
- this
FileBuilder
object - Throws:
IOException
- if an error occurs while moving the file.- Since:
- 1.5.19
-
write
Writes the specified text to the file of thisFileBuilder
.- Parameters:
text
- The text to be written to the file- Returns:
- this
FileBuilder
object - Throws:
IOException
- if an error occurs while moving the file.- Since:
- 1.5.19
-
touch
Touches the file of thisFileBuilder
.If the file does not exist, it creates a new file. If the file exists, it updates the last access and last modification time of the file.
- Returns:
- this
FileBuilder
object - Throws:
IOException
- if an error occurs while touching the file.- Since:
- 1.5.19
-
delete
Deletes the file object of thisFileBuilder
.- Returns:
- this
FileBuilder
object - Throws:
IOException
- if an error occurs while touching the file.- Since:
- 1.5.19
-
perms
Sets the permissions for the file represented by thisFileBuilder
using the specified Posix mode.- Parameters:
mode
- The mode to use for setting the permissions.- Returns:
- this
FileBuilder
instance. - Throws:
IOException
- if an error occurs while setting the permissions.- Since:
- 1.5.19
-
perms
Sets the permissions for the file represented by thisFileBuilder
using the specified permissions.- Parameters:
permissions
- The permissions to use for setting the permissions.- Returns:
- this
FileBuilder
instance. - Throws:
IOException
- if an error occurs while setting the permissions.- Since:
- 1.5.19
-