Package io.github.astrapi69.create
Class FileFactory
- java.lang.Object
-
- io.github.astrapi69.create.FileFactory
-
public final class FileFactory extends java.lang.Object
The classFileFactory
helps you to create files or directories
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static boolean
mkParentDirs(java.io.File file)
Creates the parent directories from the given file.static boolean
newDirectories(java.nio.file.Path dir, java.nio.file.attribute.FileAttribute<?>... attrs)
Creates a new directory from the givenPath
object and the optionalFileAttribute
.
Note: this method decorates theFiles.createDirectories(Path, FileAttribute...)
and returns if the directory is created or not.static FileCreationState
newDirectories(java.util.Collection<java.io.File> directories)
Creates the directories.static FileCreationState
newDirectory(java.io.File dir)
Creates a new directory from the givenFile
objectstatic boolean
newDirectory(java.nio.file.Path dir, java.nio.file.attribute.FileAttribute<?>... attrs)
Creates a new directory from the givenPath
object and the optionalFileAttribute
.
Note: this method decorates theFiles.createDirectory(Path, FileAttribute...)
and returns if the directory is created or not.static FileCreationState
newFile(java.io.File file)
Creates an empty file if the File does not exists otherwise it lets the file as it is.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 void
newParentDirectories(java.io.File file)
Deprecated.use instead new methodmkParentDirs(File)
that returns a result Note:
will be removed in next minor version
-
-
-
Method Detail
-
newDirectories
public static FileCreationState newDirectories(java.util.Collection<java.io.File> directories)
Creates the directories.- Parameters:
directories
- the directories- Returns:
- true, if successful
-
newDirectories
public static boolean newDirectories(java.nio.file.Path dir, java.nio.file.attribute.FileAttribute<?>... attrs) throws java.io.IOException
Creates a new directory from the givenPath
object and the optionalFileAttribute
.
Note: this method decorates theFiles.createDirectories(Path, FileAttribute...)
and returns if the directory is created or not.- Parameters:
dir
- the dir the directory to createattrs
- an optional list of file attributes to set atomically when creating the directory- Returns:
- Returns true if the directory was created otherwise false.
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.- See Also:
Files.createDirectories(Path, FileAttribute...)
-
newDirectory
public static FileCreationState newDirectory(java.io.File dir)
Creates a new directory from the givenFile
object- Parameters:
dir
- The directory to create- Returns:
- the
FileCreationState
with the result
-
newDirectory
public static boolean newDirectory(java.nio.file.Path dir, java.nio.file.attribute.FileAttribute<?>... attrs) throws java.io.IOException
Creates a new directory from the givenPath
object and the optionalFileAttribute
.
Note: this method decorates theFiles.createDirectory(Path, FileAttribute...)
and returns if the directory is created or not.- Parameters:
dir
- the dir the directory to createattrs
- an optional list of file attributes to set atomically when creating the directory- Returns:
- Returns true if the directory was created otherwise false.
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.- See Also:
Files.createDirectory(Path, FileAttribute...)
-
newFile
public static FileCreationState newFile(java.io.File file) throws java.io.IOException
Creates an empty file if the File does not exists otherwise it lets the file as it is.- Parameters:
file
- the file.- Returns:
- true, if the file is successful created otherwise false.
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
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:
- true, if successful
- Throws:
java.io.IOException
- Signals that an I/O exception has occurred.
-
newParentDirectories
@Deprecated public static void newParentDirectories(java.io.File file)
Deprecated.use instead new methodmkParentDirs(File)
that returns a result Note:
will be removed in next minor versionCreates the parent directories from the given file.- Parameters:
file
- the file
-
mkParentDirs
public static boolean mkParentDirs(java.io.File file)
Creates the parent directories from the given file.- Parameters:
file
- the file
-
-