public interface Createable
The Createable interface provides methods for creating files and directories with a variety of configurations and options
  • Method Details

    • newDirectories

      default Collection<FileCreationState> newDirectories(Collection<File> directories)
      Creates the directories
      Parameters:
      directories - the directories
      Returns:
      collection of FileCreationState with the result of each directory creation
    • newDirectories

      default boolean newDirectories(Path dir, FileAttribute<?>... attrs) throws IOException
      Creates new directories from the given path and optional file attributes
      Parameters:
      dir - the directory to create
      attrs - 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

      default boolean newDirectory(Path dir, FileAttribute<?>... attrs) throws IOException
      Creates a new directory from the given path and optional file attributes
      Parameters:
      dir - the directory to create
      attrs - 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

      default File newDirectory(String absolutePath) throws IOException
      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

      default FileCreationState newDirectory(File directory)
      Creates a new directory from the given File object
      Parameters:
      directory - the directory to create
      Returns:
      the FileCreationState with the result
    • newDirectory

      default File newDirectory(File parentDirectory, String directoryName)
      Factory method for creating the new directory as File objects if it does not exist
      Parameters:
      parentDirectory - the parent directory
      directoryName - the directory name
      Returns:
      the new directory as File object
    • mkParentDirs

      default boolean mkParentDirs(File file)
      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

      default FileCreationState newFile(File file) throws IOException
      Factory method that creates a new empty File 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

      default File newFile(String absolutePath) throws IOException
      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

      default File newFile(String absolutePath, boolean createIfNotExists) throws IOException
      Creates a new file from the specified absolute path, creating it if it does not exist
      Parameters:
      absolutePath - the absolute path
      createIfNotExists - 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

      default File newFile(File parentDirectory, String filename) throws IOException
      Creates a new file in the specified parent directory with the given filename
      Parameters:
      parentDirectory - the parent directory
      filename - the file name
      Returns:
      the created file as a File object
      Throws:
      IOException - Signals an I/O exception occurred
    • newFiles

      default FileCreationState newFiles(Collection<File> files) throws IOException
      Creates all files in the collection as empty files if they do not exist, otherwise leaves them as they are
      Parameters:
      files - the collection of File objects
      Returns:
      the FileCreationState object representing the overall creation result
      Throws:
      IOException - Signals that an I/O exception has occurred.