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 TypeMethodDescriptionvoidaddExclude(Path path) longlongpostVisitDirectory(Path dir, IOException e) voidsetLogger(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:
visitFilein interfaceFileVisitor<Path>- Overrides:
visitFilein classSimpleFileVisitor<Path>- Throws:
IOException
-
postVisitDirectory
- Specified by:
postVisitDirectoryin interfaceFileVisitor<Path>- Overrides:
postVisitDirectoryin classSimpleFileVisitor<Path>- Throws:
IOException
-
visitFileFailed
- Specified by:
visitFileFailedin interfaceFileVisitor<Path>- Overrides:
visitFileFailedin classSimpleFileVisitor<Path>
-