Class DeletingPathVisitor

  • All Implemented Interfaces:
    java.nio.file.FileVisitor<java.nio.file.Path>

    public class DeletingPathVisitor
    extends CountingPathVisitor
    Deletes files and directories as a visit proceeds.
    Since:
    2.7
    • Field Detail

      • skip

        private final java.lang.String[] skip
    • Constructor Detail

      • DeletingPathVisitor

        public DeletingPathVisitor​(Counters.PathCounters pathCounter,
                                   java.lang.String... skip)
        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 Detail

      • accept

        private boolean accept​(java.nio.file.Path path)
        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.
      • postVisitDirectory

        public java.nio.file.FileVisitResult postVisitDirectory​(java.nio.file.Path dir,
                                                                java.io.IOException exc)
                                                         throws java.io.IOException
        Specified by:
        postVisitDirectory in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Overrides:
        postVisitDirectory in class CountingPathVisitor
        Throws:
        java.io.IOException
      • preVisitDirectory

        public java.nio.file.FileVisitResult preVisitDirectory​(java.nio.file.Path dir,
                                                               java.nio.file.attribute.BasicFileAttributes attrs)
                                                        throws java.io.IOException
        Specified by:
        preVisitDirectory in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Overrides:
        preVisitDirectory in class java.nio.file.SimpleFileVisitor<java.nio.file.Path>
        Throws:
        java.io.IOException
      • visitFile

        public java.nio.file.FileVisitResult visitFile​(java.nio.file.Path file,
                                                       java.nio.file.attribute.BasicFileAttributes attrs)
                                                throws java.io.IOException
        Specified by:
        visitFile in interface java.nio.file.FileVisitor<java.nio.file.Path>
        Overrides:
        visitFile in class CountingPathVisitor
        Throws:
        java.io.IOException