Package org.apache.commons.io.file
Class CleaningPathVisitor
java.lang.Object
java.nio.file.SimpleFileVisitor<Path>
org.apache.commons.io.file.SimplePathVisitor
org.apache.commons.io.file.CountingPathVisitor
org.apache.commons.io.file.CleaningPathVisitor
- All Implemented Interfaces:
FileVisitor<Path>,PathVisitor
Deletes files but not directories as a visit proceeds.
- Since:
- 2.7
-
Field Summary
FieldsFields inherited from class org.apache.commons.io.file.CountingPathVisitor
EMPTY_STRING_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionCleaningPathVisitor(Counters.PathCounters pathCounter, String... skip) Constructs a new visitor that deletes files except for the files and directories explicitly given.CleaningPathVisitor(Counters.PathCounters pathCounter, DeleteOption[] deleteOption, String... skip) Constructs a new visitor that deletes files except for the files and directories explicitly given. -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanReturns true to process the given path, false if not.booleaninthashCode()preVisitDirectory(Path dir, BasicFileAttributes attributes) visitFile(Path file, BasicFileAttributes attributes) static CountingPathVisitorCreates a new instance configured with a BigIntegerCounters.PathCounters.static CountingPathVisitorCreates a new instance configured with a longCounters.PathCounters.Methods inherited from class org.apache.commons.io.file.CountingPathVisitor
getPathCounters, postVisitDirectory, toString, updateDirCounter, updateFileCountersMethods inherited from class java.nio.file.SimpleFileVisitor
visitFileFailedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.nio.file.FileVisitor
visitFileFailed
-
Field Details
-
skip
-
overrideReadOnly
private final boolean overrideReadOnly
-
-
Constructor Details
-
CleaningPathVisitor
public CleaningPathVisitor(Counters.PathCounters pathCounter, DeleteOption[] deleteOption, String... skip) Constructs a new visitor that deletes files except for the files and directories explicitly given.- Parameters:
pathCounter- How to count visits.deleteOption- How deletion is handled.skip- The files to skip deleting.- Since:
- 2.8.0
-
CleaningPathVisitor
Constructs a new visitor that deletes files except for the files and directories explicitly given.- Parameters:
pathCounter- How to count visits.skip- The files to skip deleting.
-
-
Method Details
-
withBigIntegerCounters
Creates a new instance configured with a BigIntegerCounters.PathCounters.- Returns:
- a new instance configured with a BigInteger
Counters.PathCounters.
-
withLongCounters
Creates a new instance configured with a longCounters.PathCounters.- Returns:
- a new instance configured with a long
Counters.PathCounters.
-
accept
Returns true to process the given path, false if not.- Parameters:
path- the path to test.- Returns:
- true to process the given path, false if not.
-
equals
- Overrides:
equalsin classCountingPathVisitor
-
hashCode
public int hashCode()- Overrides:
hashCodein classCountingPathVisitor
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException - Specified by:
preVisitDirectoryin interfaceFileVisitor<Path>- Overrides:
preVisitDirectoryin classCountingPathVisitor- Throws:
IOException
-
visitFile
- Specified by:
visitFilein interfaceFileVisitor<Path>- Overrides:
visitFilein classCountingPathVisitor- Throws:
IOException
-