Package com.helger.commons.io.file
Class FileOperationManager
java.lang.Object
com.helger.commons.io.file.FileOperationManager
- All Implemented Interfaces:
IFileOperationManager
Manage file operations, and persist the last errors for later retrieval, as
well as offering a callback mechanism for success/error handling.
- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncopyDirRecursive(File aSourceDir, File aTargetDir) Copy a directory including all child objects.Copies the source file to the target file.Create a new directory.createDirIfNotExisting(File aDir) Create a new directory if it does not exist.createDirRecursive(File aDir) Create a new directory.Create a new directory if it does not exist.Delete an existing directory.deleteDirIfExisting(File aDir) Delete an existing directory if it is existing.deleteDirRecursive(File aDir) Delete an existing directory including all child objects.Delete an existing directory including all child objects if it is existing.deleteFile(File aFile) Delete an existing file.deleteFileIfExisting(File aFile) Delete a file if it is existing.Rename a directory.renameFile(File aSourceFile, File aTargetFile) Rename a file.toString()
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
FileOperationManager
public FileOperationManager()
-
-
Method Details
-
callbacks
-
getLastError
- Specified by:
getLastErrorin interfaceIFileOperationManager- Returns:
- The last error that occurred. May be
nullif no action was yet performed.
-
getLastOperation
- Specified by:
getLastOperationin interfaceIFileOperationManager- Returns:
- The last operation that was executed, independent of error or
success. May be
nullif no action was performed yet.
-
createDir
Description copied from interface:IFileOperationManagerCreate a new directory. The direct parent directory already needs to exist.- Specified by:
createDirin interfaceIFileOperationManager- Parameters:
aDir- The directory to be created. May not benull.- Returns:
- A non-
nullerror code.
-
createDirIfNotExisting
Description copied from interface:IFileOperationManagerCreate a new directory if it does not exist. The direct parent directory already needs to exist.- Specified by:
createDirIfNotExistingin interfaceIFileOperationManager- Parameters:
aDir- The directory to be created if it does not exist. May not benull.- Returns:
- A non-
nullerror code.
-
createDirRecursive
Description copied from interface:IFileOperationManagerCreate a new directory. The parent directories are created if they are missing.- Specified by:
createDirRecursivein interfaceIFileOperationManager- Parameters:
aDir- The directory to be created. May not benull.- Returns:
- A non-
nullerror code.
-
createDirRecursiveIfNotExisting
Description copied from interface:IFileOperationManagerCreate a new directory if it does not exist. The direct parent directory already needs to exist.- Specified by:
createDirRecursiveIfNotExistingin interfaceIFileOperationManager- Parameters:
aDir- The directory to be created if it does not exist. May not benull.- Returns:
- A non-
nullerror code.
-
deleteDir
Description copied from interface:IFileOperationManagerDelete an existing directory. The directory needs to be empty before it can be deleted.- Specified by:
deleteDirin interfaceIFileOperationManager- Parameters:
aDir- The directory to be deleted. May not benull.- Returns:
- A non-
nullerror code.
-
deleteDirIfExisting
Description copied from interface:IFileOperationManagerDelete an existing directory if it is existing. The directory needs to be empty before it can be deleted.- Specified by:
deleteDirIfExistingin interfaceIFileOperationManager- Parameters:
aDir- The directory to be deleted. May not benull.- Returns:
- A non-
nullerror code.
-
deleteDirRecursive
Description copied from interface:IFileOperationManagerDelete an existing directory including all child objects.- Specified by:
deleteDirRecursivein interfaceIFileOperationManager- Parameters:
aDir- The directory to be deleted. May not benull.- Returns:
- A non-
nullerror code.
-
deleteDirRecursiveIfExisting
Description copied from interface:IFileOperationManagerDelete an existing directory including all child objects if it is existing.- Specified by:
deleteDirRecursiveIfExistingin interfaceIFileOperationManager- Parameters:
aDir- The directory to be deleted. May not benull.- Returns:
- A non-
nullerror code.
-
deleteFile
Description copied from interface:IFileOperationManagerDelete an existing file.- Specified by:
deleteFilein interfaceIFileOperationManager- Parameters:
aFile- The file to be deleted. May not benull.- Returns:
- A non-
nullerror code.
-
deleteFileIfExisting
Description copied from interface:IFileOperationManagerDelete a file if it is existing.- Specified by:
deleteFileIfExistingin interfaceIFileOperationManager- Parameters:
aFile- The file to be deleted. May not benull.- Returns:
- A non-
nullerror code.
-
renameDir
Description copied from interface:IFileOperationManagerRename a directory.- Specified by:
renameDirin interfaceIFileOperationManager- Parameters:
aSourceDir- The original directory name. May not benull.aTargetDir- The destination directory name. May not benull.- Returns:
- A non-
nullerror code.
-
renameFile
Description copied from interface:IFileOperationManagerRename a file.- Specified by:
renameFilein interfaceIFileOperationManager- Parameters:
aSourceFile- The original file name. May not benull.aTargetFile- The destination file name. May not benull.- Returns:
- A non-
nullerror code.
-
copyDirRecursive
Description copied from interface:IFileOperationManagerCopy a directory including all child objects.- Specified by:
copyDirRecursivein interfaceIFileOperationManager- Parameters:
aSourceDir- The source directory to be copied. May not benull.aTargetDir- The destination directory where to be copied. This directory may not be existing. May not benull.- Returns:
- A non-
nullerror code.
-
copyFile
Description copied from interface:IFileOperationManagerCopies the source file to the target file.- Specified by:
copyFilein interfaceIFileOperationManager- Parameters:
aSourceFile- The source file to use. May not benull. Needs to be an existing file.aTargetFile- The destination files. May not benulland may not be an existing file.- Returns:
- A non-
nullerror code.
-
toString
-