java.lang.Object
io.github.astrapi69.file.create.FileFactory

public final class FileFactory extends Object
The class FileFactory provides utility methods for creating files
  • Method Details

    • newFile

      public static 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.
    • newFileQuietly

      public static FileCreationState newFileQuietly(File file)
      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
    • newFile

      public static File newFile(String absolutePath) throws IOException
      Factory method that creates a new File object, if the given boolean flag is true a new empty file will be created on the file system
      Parameters:
      absolutePath - the absolute path
      Returns:
      the file object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • newFileQuietly

      public static File newFileQuietly(String absolutePath)
      Factory method that creates a new File object, if the given boolean flag is true a new empty file will be created on the file system
      Parameters:
      absolutePath - the absolute path
      Returns:
      the file object
    • newFile

      public static File newFile(String absolutePath, boolean createIfNotExists) throws IOException
      Creates a new File object; if the specified flag is true, an empty file is created on the file system
      Parameters:
      absolutePath - the absolute path
      createIfNotExists - if true, creates the file if it does not exist
      Returns:
      the file object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • newFileQuietly

      public static File newFileQuietly(String absolutePath, boolean createIfNotExists)
      Creates a new File object; if the specified flag is true, an empty file is created on the file system
      Parameters:
      absolutePath - the absolute path
      createIfNotExists - if true, creates the file if it does not exist
      Returns:
      the file object
    • newFile

      public static File newFile(File parentDirectory, String filename) throws IOException
      Creates a new File object in the specified directory if it does not exist
      Parameters:
      parentDirectory - the parent directory
      filename - the file name
      Returns:
      the new File object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • newFileQuietly

      public static File newFileQuietly(File parentDirectory, String filename)
      Factory method for creating the new File object if it does not exist
      Parameters:
      parentDirectory - the parent directory
      filename - the file name
      Returns:
      the new File object
    • newFile

      public static File newFile(String parentDirectory, String filename) throws IOException
      Factory method for creating the new File if it is not exists.
      Parameters:
      parentDirectory - the parent directory
      filename - the file name
      Returns:
      the new File object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • newFileQuietly

      public static File newFileQuietly(String parentDirectory, String filename)
      Factory method for creating the new File if it is not exists.
      Parameters:
      parentDirectory - the parent directory
      filename - the file name
      Returns:
      the new File object
    • newFile

      public static File newFile(FileInfo fileInfo) throws IOException
      Factory method for creating the new File from the given FileInfo object
      Parameters:
      fileInfo - the FileInfo object
      Returns:
      the new File object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • newFileQuietly

      public static File newFileQuietly(FileInfo fileInfo)
      Factory method for creating the new File from the given FileInfo object
      Parameters:
      fileInfo - the FileInfo object
      Returns:
      the new File object
    • newFiles

      public static 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.
    • newFilesQuietly

      public static FileCreationState newFilesQuietly(Collection<File> files)
      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