Class Scanner

java.lang.Object
org.glassfish.pfl.basic.tools.file.Scanner

public class Scanner extends Object
Recursively scan directories to process files.
  • Field Details

    • roots

      private final List<File> roots
    • verbose

      private final int verbose
    • patternsToSkip

      private List<String> patternsToSkip
  • Constructor Details

    • Scanner

      public Scanner(int verbose, List<File> files)
    • Scanner

      public Scanner(int verbose, File... files)
  • Method Details

    • addDirectoryToSkip

      public void addDirectoryToSkip(String pattern)
      Add a pattern that defines a directory to skip. We only need really simple patterns: just a single name that must match a component of a directory name exactly.
    • scan

      public boolean scan(Scanner.Action action) throws IOException
      Scan all files reachable from roots. Does a depth-first search. Ignores all directories (and their contents) that match an entry in patternsToSkip. Passes each file (not directories) to the action. If action returns false, scan terminates. The result of the scan is the result of the last action call.
      Throws:
      IOException
    • doScan

      private boolean doScan(File file, Scanner.Action action) throws IOException
      Throws:
      IOException
    • skipDirectory

      private boolean skipDirectory(File file)
    • match

      private boolean match(String pattern, String fname)