Interface Createable
public interface Createable
The
Createable
interface provides methods for creating files and directories with a
variety of configurations and options-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
mkParentDirs
(File file) Creates parent directories for the given file if they do not already existdefault boolean
newDirectories
(Path dir, FileAttribute<?>... attrs) Creates new directories from the given path and optional file attributesdefault Collection<FileCreationState>
newDirectories
(Collection<File> directories) Creates the directoriesdefault FileCreationState
newDirectory
(File directory) Creates a new directory from the givenFile
objectdefault File
newDirectory
(File parentDirectory, String directoryName) Factory method for creating the new directory asFile
objects if it does not existdefault File
newDirectory
(String absolutePath) Creates a new directory from the specified absolute pathdefault boolean
newDirectory
(Path dir, FileAttribute<?>... attrs) Creates a new directory from the given path and optional file attributesdefault FileCreationState
Factory method that creates a new emptyFile
if it does not exist, otherwise it leaves the file as it isdefault File
Creates a new file in the specified parent directory with the given filenamedefault File
Creates a new file from the specified absolute pathdefault File
Creates a new file from the specified absolute path, creating it if it does not existdefault FileCreationState
newFiles
(Collection<File> files) Creates all files in the collection as empty files if they do not exist, otherwise leaves them as they are
-
Method Details
-
newDirectories
Creates the directories- Parameters:
directories
- the directories- Returns:
- collection of
FileCreationState
with the result of each directory creation
-
newDirectories
Creates new directories from the given path and optional file attributes- Parameters:
dir
- the directory to createattrs
- optional file attributes to set atomically when creating the directory- Returns:
- true if the directories were created; false otherwise
- Throws:
IOException
- Signals an I/O exception occurred
-
newDirectory
Creates a new directory from the given path and optional file attributes- Parameters:
dir
- the directory to createattrs
- optional file attributes to set atomically when creating the directory- Returns:
- true if the directory was created; false otherwise
- Throws:
IOException
- Signals an I/O exception occurred
-
newDirectory
Creates a new directory from the specified absolute path- Parameters:
absolutePath
- the absolute path- Returns:
- the created directory as a
File
object - Throws:
IOException
- Signals an I/O exception occurred
-
newDirectory
Creates a new directory from the givenFile
object- Parameters:
directory
- the directory to create- Returns:
- the
FileCreationState
with the result
-
newDirectory
Factory method for creating the new directory asFile
objects if it does not exist- Parameters:
parentDirectory
- the parent directorydirectoryName
- the directory name- Returns:
- the new directory as
File
object
-
mkParentDirs
Creates parent directories for the given file if they do not already exist- Parameters:
file
- the file for which parent directories need to be created- Returns:
- true if the parent directories were created successfully; false otherwise
-
newFile
Factory method that creates a new emptyFile
if it does not exist, otherwise it leaves the file as it is- Parameters:
file
- the file.- Returns:
- the state describing the creation outcome
- Throws:
IOException
- Signals that an I/O exception has occurred.
-
newFile
Creates a new file from the specified absolute path- Parameters:
absolutePath
- the absolute path- Returns:
- the created file as a
File
object - Throws:
IOException
- Signals an I/O exception occurred
-
newFile
Creates a new file from the specified absolute path, creating it if it does not exist- Parameters:
absolutePath
- the absolute pathcreateIfNotExists
- flag indicating if the file should be created if it does not exist- Returns:
- the created file as a
File
object - Throws:
IOException
- Signals an I/O exception occurred
-
newFile
Creates a new file in the specified parent directory with the given filename- Parameters:
parentDirectory
- the parent directoryfilename
- the file name- Returns:
- the created file as a
File
object - Throws:
IOException
- Signals an I/O exception occurred
-
newFiles
Creates all files in the collection as empty files if they do not exist, otherwise leaves them as they are- Parameters:
files
- the collection ofFile
objects- Returns:
- the
FileCreationState
object representing the overall creation result - Throws:
IOException
- Signals that an I/O exception has occurred.
-