- java.lang.Object
-
- io.github.astrapi69.file.create.FileFactory
-
public final class FileFactory extends java.lang.Object
The classFileFactory
helps you to create files
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.io.File
newFile(FileInfo fileInfo)
Factory method for creating the newFile
from the givenFileInfo
objectstatic FileCreationState
newFile(java.io.File file)
Factory method that creates a new emptyFile
if it is not exists, otherwise it lets the file as it is.static java.io.File
newFile(java.io.File parentDirectory, java.lang.String filename)
Factory method for creating the newFile
if it is not exists.static java.io.File
newFile(java.lang.String absolutePath)
Factory method that creates a newFile
object, if the given boolean flag is true a new empty file will be created on the file systemstatic java.io.File
newFile(java.lang.String absolutePath, boolean createIfNotExists)
Factory method that creates a newFile
object, if the given boolean flag is true a new empty file will be created on the file systemstatic java.io.File
newFile(java.lang.String parentDirectory, java.lang.String filename)
Factory method for creating the newFile
if it is not exists.static java.io.File
newFileQuietly(FileInfo fileInfo)
Factory method for creating the newFile
from the givenFileInfo
objectstatic FileCreationState
newFileQuietly(java.io.File file)
Factory method that creates a new emptyFile
if it is not exists, otherwise it lets the file as it is.static java.io.File
newFileQuietly(java.io.File parentDirectory, java.lang.String filename)
Factory method for creating the newFile
if it is not exists.static java.io.File
newFileQuietly(java.lang.String absolutePath)
Factory method that creates a newFile
object, if the given boolean flag is true a new empty file will be created on the file systemstatic java.io.File
newFileQuietly(java.lang.String absolutePath, boolean createIfNotExists)
Factory method that creates a newFile
object, if the given boolean flag is true a new empty file will be created on the file systemstatic java.io.File
newFileQuietly(java.lang.String parentDirectory, java.lang.String filename)
Factory method for creating the newFile
if it is not exists.static FileCreationState
newFiles(java.util.Collection<java.io.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.static FileCreationState
newFilesQuietly(java.util.Collection<java.io.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.
-
-
-
Method Detail
-
newFile
public static FileCreationState newFile(java.io.File file) throws java.io.IOException
Factory method that creates a new emptyFile
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:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newFileQuietly
public static FileCreationState newFileQuietly(java.io.File file)
Factory method that creates a new emptyFile
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 java.io.File newFile(java.lang.String absolutePath) throws java.io.IOException
Factory method that creates a newFile
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:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newFileQuietly
public static java.io.File newFileQuietly(java.lang.String absolutePath)
Factory method that creates a newFile
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 java.io.File newFile(java.lang.String absolutePath, boolean createIfNotExists) throws java.io.IOException
Factory method that creates a newFile
object, if the given boolean flag is true a new empty file will be created on the file system- Parameters:
absolutePath
- the absolute pathcreateIfNotExists
- if this flag is true the file will be created if it does not exists- Returns:
- the file object
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newFileQuietly
public static java.io.File newFileQuietly(java.lang.String absolutePath, boolean createIfNotExists)
Factory method that creates a newFile
object, if the given boolean flag is true a new empty file will be created on the file system- Parameters:
absolutePath
- the absolute pathcreateIfNotExists
- if this flag is true the file will be created if it does not exists- Returns:
- the file object
-
newFile
public static java.io.File newFile(java.io.File parentDirectory, java.lang.String filename) throws java.io.IOException
Factory method for creating the newFile
if it is not exists.- Parameters:
parentDirectory
- the parent directoryfilename
- the file name- Returns:
- the new
File
object - Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newFileQuietly
public static java.io.File newFileQuietly(java.io.File parentDirectory, java.lang.String filename)
Factory method for creating the newFile
if it is not exists.- Parameters:
parentDirectory
- the parent directoryfilename
- the file name- Returns:
- the new
File
object
-
newFile
public static java.io.File newFile(java.lang.String parentDirectory, java.lang.String filename) throws java.io.IOException
Factory method for creating the newFile
if it is not exists.- Parameters:
parentDirectory
- the parent directoryfilename
- the file name- Returns:
- the new
File
object - Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newFileQuietly
public static java.io.File newFileQuietly(java.lang.String parentDirectory, java.lang.String filename)
Factory method for creating the newFile
if it is not exists.- Parameters:
parentDirectory
- the parent directoryfilename
- the file name- Returns:
- the new
File
object
-
newFile
public static java.io.File newFile(FileInfo fileInfo) throws java.io.IOException
Factory method for creating the newFile
from the givenFileInfo
object- Parameters:
fileInfo
- theFileInfo
object- Returns:
- the new
File
object - Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newFileQuietly
public static java.io.File newFileQuietly(FileInfo fileInfo)
Factory method for creating the newFile
from the givenFileInfo
object- Parameters:
fileInfo
- theFileInfo
object- Returns:
- the new
File
object
-
newFiles
public static FileCreationState newFiles(java.util.Collection<java.io.File> files) throws java.io.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:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newFilesQuietly
public static FileCreationState newFilesQuietly(java.util.Collection<java.io.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
-
-