Package io.github.astrapi69.file.copy
Class CopyDirectoryExtensions
java.lang.Object
io.github.astrapi69.file.copy.CopyDirectoryExtensions
The class
CopyDirectoryExtensions
helps you to copy directories-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
copyDirectory
(File source, File destination) Copies the given source directory to the given destination directory.static boolean
copyDirectory
(File source, File destination, boolean lastModified) Copies the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.static boolean
copyDirectory
(Path source, Path destination) Copies the given source directory to the destination directorystatic boolean
copyDirectoryWithFileFilter
(File source, File destination, FileFilter fileFilter, boolean lastModified) Copies all files that match to the FileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.static boolean
copyDirectoryWithFileFilter
(File source, File destination, FileFilter includeFileFilter, FileFilter excludeFileFilter, boolean lastModified) Copies all files that match to the given includeFileFilter and does not copy all the files that match the excludeFileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.static boolean
copyDirectoryWithFileFilter
(File source, File destination, FileFilter includeFileFilter, FileFilter excludeFileFilter, Collection<File> excludeFiles, boolean lastModified) Copies all files that match to the given includeFileFilter and does not copy all the files that match the excludeFileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.static boolean
copyDirectoryWithFilenameFilter
(File source, File destination, FilenameFilter filenameFilter, boolean lastModified) Copies all files that match to the FilenameFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.static boolean
copyDirectoryWithFilenameFilter
(File source, File destination, FilenameFilter includeFilenameFilter, FilenameFilter excludeFilenameFilter, boolean lastModified) Copies all files that match to the given includeFilenameFilter and does not copy all the files that match the excludeFilenameFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.
-
Method Details
-
copyDirectory
Copies the given source directory to the destination directory- Parameters:
source
- The source directorydestination
- The destination directory- Returns:
- true if the directory was successfully copied, otherwise false
- Throws:
IOException
- if an I/O error occurs during the copy
-
copyDirectory
public static boolean copyDirectory(File source, File destination) throws FileIsSecurityRestrictedException, IOException, FileIsADirectoryException, FileIsNotADirectoryException, DirectoryAlreadyExistsException Copies the given source directory to the given destination directory.- Parameters:
source
- The source directory.destination
- The destination directory.- Returns:
- 's true if the directory is copied, otherwise false.
- Throws:
FileIsSecurityRestrictedException
- Is thrown if the source file is security restricted.IOException
- Is thrown if an error occurs by reading or writing.FileIsADirectoryException
- Is thrown if the destination file is a directory.FileIsNotADirectoryException
- Is thrown if the source file is not a directory.DirectoryAlreadyExistsException
- Is thrown if the directory already exists.
-
copyDirectory
public static boolean copyDirectory(File source, File destination, boolean lastModified) throws FileIsSecurityRestrictedException, IOException, FileIsADirectoryException, FileIsNotADirectoryException, DirectoryAlreadyExistsException Copies the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.- Parameters:
source
- The source directory.destination
- The destination directory.lastModified
- The Flag tells if the attribute lastModified has to be set with the attribute from the destination file.- Returns:
- 's true if the directory is copied, otherwise false.
- Throws:
FileIsSecurityRestrictedException
- Is thrown if the source file is security restricted.IOException
- Is thrown if an error occurs by reading or writing.FileIsADirectoryException
- Is thrown if the destination file is a directory.FileIsNotADirectoryException
- Is thrown if the source file is not a directory.DirectoryAlreadyExistsException
- Is thrown if the directory already exists.
-
copyDirectoryWithFileFilter
public static boolean copyDirectoryWithFileFilter(File source, File destination, FileFilter fileFilter, boolean lastModified) throws IOException, FileIsNotADirectoryException, FileIsADirectoryException, FileIsSecurityRestrictedException, DirectoryAlreadyExistsException Copies all files that match to the FileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.- Parameters:
source
- The source directory.destination
- The destination directory.fileFilter
- The FileFilter for the files to be copied. If null all files will be copied.lastModified
- Flag the tells if the attribute lastModified has to be set with the attribute from the destination file.- Returns:
- 's true if the directory is copied, otherwise false.
- Throws:
IOException
- Is thrown if an error occurs by reading or writing.FileIsNotADirectoryException
- Is thrown if the source file is not a directory.FileIsADirectoryException
- Is thrown if the destination file is a directory.FileIsSecurityRestrictedException
- Is thrown if the source file is security restricted.DirectoryAlreadyExistsException
- Is thrown if the directory all ready exists.
-
copyDirectoryWithFileFilter
public static boolean copyDirectoryWithFileFilter(File source, File destination, FileFilter includeFileFilter, FileFilter excludeFileFilter, boolean lastModified) throws IOException, FileIsNotADirectoryException, FileIsADirectoryException, FileIsSecurityRestrictedException, DirectoryAlreadyExistsException Copies all files that match to the given includeFileFilter and does not copy all the files that match the excludeFileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.- Parameters:
source
- The source directory.destination
- The destination directory.includeFileFilter
- The FileFilter for the files to be copied. If null all files will be copied.excludeFileFilter
- The FileFilter for the files to be not copied. If null no files will be excluded by copy process.lastModified
- Flag the tells if the attribute lastModified has to be set with the attribute from the destination file.- Returns:
- 's true if the directory is copied, otherwise false.
- Throws:
IOException
- Is thrown if an error occurs by reading or writing.FileIsNotADirectoryException
- Is thrown if the source file is not a directory.FileIsADirectoryException
- Is thrown if the source or destination file is a directory.FileIsSecurityRestrictedException
- Is thrown if the source file is security restricted.DirectoryAlreadyExistsException
- Is thrown if the directory all ready exists.
-
copyDirectoryWithFileFilter
public static boolean copyDirectoryWithFileFilter(File source, File destination, FileFilter includeFileFilter, FileFilter excludeFileFilter, Collection<File> excludeFiles, boolean lastModified) throws IOException, FileIsNotADirectoryException, FileIsADirectoryException, FileIsSecurityRestrictedException, DirectoryAlreadyExistsException Copies all files that match to the given includeFileFilter and does not copy all the files that match the excludeFileFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.- Parameters:
source
- The source directory.destination
- The destination directory.includeFileFilter
- The FileFilter for the files to be copied. If null all files will be copied.excludeFileFilter
- The FileFilter for the files to be not copied. If null no files will be excluded by copy process.excludeFiles
- A list of files that should be not copied. If null no files will be excluded by copy process.lastModified
- Flag the tells if the attribute lastModified has to be set with the attribute from the destination file.- Returns:
- 's true if the directory is copied, otherwise false.
- Throws:
IOException
- Is thrown if an error occurs by reading or writing.FileIsNotADirectoryException
- Is thrown if the source file is not a directory.FileIsADirectoryException
- Is thrown if the source or destination file is a directory.FileIsSecurityRestrictedException
- Is thrown if the source file is security restricted.DirectoryAlreadyExistsException
- Is thrown if the directory all ready exists.
-
copyDirectoryWithFilenameFilter
public static boolean copyDirectoryWithFilenameFilter(File source, File destination, FilenameFilter filenameFilter, boolean lastModified) throws IOException, FileIsNotADirectoryException, FileIsSecurityRestrictedException Copies all files that match to the FilenameFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.- Parameters:
source
- The source directory.destination
- The destination directory.filenameFilter
- The FilenameFilter for the files to be copied. If null all files will be copied.lastModified
- Flag the tells if the attribute lastModified has to be set with the attribute from the destination file.- Returns:
- 's true if the directory is copied, otherwise false.
- Throws:
IOException
- Is thrown if an error occurs by reading or writing.FileIsNotADirectoryException
- Is thrown if the source file is not a directory.FileIsSecurityRestrictedException
- Is thrown if the source file is security restricted.
-
copyDirectoryWithFilenameFilter
public static boolean copyDirectoryWithFilenameFilter(File source, File destination, FilenameFilter includeFilenameFilter, FilenameFilter excludeFilenameFilter, boolean lastModified) throws IOException, FileIsNotADirectoryException, FileIsSecurityRestrictedException Copies all files that match to the given includeFilenameFilter and does not copy all the files that match the excludeFilenameFilter from the given source directory to the given destination directory with the option to set the lastModified time from the given destination file or directory.- Parameters:
source
- The source directory.destination
- The destination directory.includeFilenameFilter
- The FilenameFilter for the files to be copied. If null all files will be copied.excludeFilenameFilter
- The FilenameFilter for the files to be not copied. If null no files will be excluded by copy process.lastModified
- Flag the tells if the attribute lastModified has to be set with the attribute from the destination file.- Returns:
- 's true if the directory is copied, otherwise false.
- Throws:
IOException
- Is thrown if an error occurs by reading or writing.FileIsNotADirectoryException
- Is thrown if the source file is not a directory.FileIsSecurityRestrictedException
- Is thrown if the source file is security restricted.
-