Package com.illumon.util.files
Class FileHelper
java.lang.Object
com.illumon.util.files.FileHelper
public class FileHelper extends Object
Utility/helper methods for file operations.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFileHelper.FileDeletionExceptionGive callers ofdeleteRecursivelyOnNFS(File, Pattern)a better exception to catch. -
Method Summary
Modifier and Type Method Description static booleandeleteRecursivelyOnNFS(File trashFile, File fileToBeDeleted, Pattern excludePattern)AugmentFileUtils.deleteRecursivelyOnNFS(File, File)with an exclude pattern.static booleandeleteRecursivelyOnNFS(File file, String excludePattern)AugmentFileUtils.deleteRecursivelyOnNFS(File)with an exclude pattern.static booleandeleteRecursivelyOnNFS(File file, Pattern excludePattern)AugmentFileUtils.deleteRecursivelyOnNFS(File)with an exclude pattern.static StringgetCanonicalForm(String path)Get the canonical path for the given path string, converting IOExceptions to UncheckIOException.
-
Method Details
-
getCanonicalForm
Get the canonical path for the given path string, converting IOExceptions to UncheckIOException.- Parameters:
path- The file (as String) for which to get the canonical form.- Returns:
- the canonical file string.
-
deleteRecursivelyOnNFS
AugmentFileUtils.deleteRecursivelyOnNFS(File)with an exclude pattern. Files matching the pattern will not be removed, nor will containing directories.- Parameters:
file- the file or folder to delete.excludePattern- don't delete files or folders matching this pattern.- Returns:
- true if any files were excluded (so caller will know if a directory is empty)
- Throws:
FileHelper.FileDeletionException- on any errors moving/renaming/deleting files
-
deleteRecursivelyOnNFS
AugmentFileUtils.deleteRecursivelyOnNFS(File)with an exclude pattern. Files matching the pattern will not be removed, nor will containing directories.- Parameters:
file- the file or folder to delete.excludePattern- don't delete files or folders matching this pattern.- Returns:
- true if any files were excluded (so caller will know if a directory is empty)
- Throws:
FileHelper.FileDeletionException- on any errors moving/renaming/deleting files
-
deleteRecursivelyOnNFS
public static boolean deleteRecursivelyOnNFS(File trashFile, File fileToBeDeleted, @Nullable Pattern excludePattern)AugmentFileUtils.deleteRecursivelyOnNFS(File, File)with an exclude pattern. Files matching the pattern will not be removed, nor will containing directories.This is an implementation method for
deleteRecursivelyOnNFS(File, String)- Parameters:
trashFile- Filename to move regular files to before deletion. .nfs files may be created in its parent directory.fileToBeDeleted- File or directory at which to begin recursive deletion.excludePattern- don't delete files or folders matching this pattern.- Returns:
- true if any files were excluded (so caller will know if a directory is empty)
- Throws:
FileHelper.FileDeletionException- on any errors moving/renaming/deleting files
-