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

public final class FileFactory extends Object
The class FileFactory helps you to create files
  • Method Details

    • newFile

      public static FileCreationState newFile(File file) throws IOException
      Factory method that creates a new empty File if it is not exists, otherwise it lets the file as it is.
      Parameters:
      file - the file.
      Returns:
      the appropriate state object that describes what happen
      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 is not exists, otherwise it lets the file as it is.
      Parameters:
      file - the file.
      Returns:
      the appropriate state object that describes what happen
    • 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
      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
      createIfNotExists - if this flag is true the file will be created if it does not exists
      Returns:
      the file object
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • newFileQuietly

      public static File newFileQuietly(String absolutePath, boolean createIfNotExists)
      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
      createIfNotExists - if this flag is true the file will be created if it does not exists
      Returns:
      the file object
    • newFile

      public static File newFile(File 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(File 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(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 contained in the collection as empty files if the files does not exists otherwise it lets the files as they are.
      Parameters:
      files - the Collection with the File objects.
      Returns:
      the FileCreationState object that encapsulate the creation result
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • newFilesQuietly

      public static FileCreationState newFilesQuietly(Collection<File> files)
      Creates all files contained in the collection as empty files if the files does not exists otherwise it lets the files as they are.
      Parameters:
      files - the Collection with the File objects.
      Returns:
      the FileCreationState object that encapsulate the creation result