Class FileCollector
java.lang.Object
org.matwoess.jsourceprofiler.tool.cli.FileCollector
Collects files with a specific file extension from a directory and its subdirectories.
The collected files can be filtered by excluding specific file names and paths.
Whether to include hidden directories can be specified.
-
Constructor Summary
ConstructorsConstructorDescriptionFileCollector(Path baseDir, String fileExtension, boolean excludeHiddenDirs) Creates a new FileCollector for the given base directory and file extension. -
Method Summary
Modifier and TypeMethodDescriptioncollect()Collects the files from the base directory and its subdirectories usingFiles.walkFileTreeand a custom visitor.excludeFileName(String fileName) Adds a file name to the list of exclusions.excludePath(Path exclusion) Adds a path to the list of exclusions.
-
Constructor Details
-
FileCollector
Creates a new FileCollector for the given base directory and file extension. The file extension is case-insensitive and should not contain a leading dot.- Parameters:
baseDir- the base directory to start the search fromfileExtension- the file extension to collect files forexcludeHiddenDirs- whether to exclude hidden directories from the search
-
-
Method Details
-
excludeFileName
Adds a file name to the list of exclusions.- Parameters:
fileName- the file name to exclude- Returns:
- this FileCollector instance
-
excludePath
Adds a path to the list of exclusions.- Parameters:
exclusion- the path to exclude- Returns:
- this FileCollector instance
-
collect
Collects the files from the base directory and its subdirectories usingFiles.walkFileTreeand a custom visitor. The collected files are filtered by the file extension and the exclusion lists. Hidden directory tree paths are excluded if specified.- Returns:
- a list of paths to the collected files
-