Class DeletingFileVisitor
- All Implemented Interfaces:
FileVisitor<Path>
Enables
Files.walkFileTree(Path, FileVisitor)
to recursively delete
a directory's contents.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExclude
(Path path) long
long
postVisitDirectory
(Path dir, IOException e) void
setLogger
(org.slf4j.Logger logger) visitFile
(Path file, BasicFileAttributes attributes) visitFileFailed
(Path file, IOException e) Methods inherited from class java.nio.file.SimpleFileVisitor
preVisitDirectory
-
Constructor Details
-
DeletingFileVisitor
public DeletingFileVisitor()
-
-
Method Details
-
getDeletedFileCount
public long getDeletedFileCount()- Returns:
- Total number of deleted files.
-
getDeletedFileSize
public long getDeletedFileSize()- Returns:
- Total byte size of all deleted files.
-
setLogger
public void setLogger(org.slf4j.Logger logger) -
addExclude
- Parameters:
path
- Path to exclude from the deletion.
-
visitFile
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Overrides:
visitFile
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
postVisitDirectory
- Specified by:
postVisitDirectory
in interfaceFileVisitor<Path>
- Overrides:
postVisitDirectory
in classSimpleFileVisitor<Path>
- Throws:
IOException
-
visitFileFailed
- Specified by:
visitFileFailed
in interfaceFileVisitor<Path>
- Overrides:
visitFileFailed
in classSimpleFileVisitor<Path>
-