Hi,
I tested the solution below with the following assumptions:
1) All search criterias must be met (logical AND);
2) Directory is added to foundFiles only when is not searched for content
Please, help me to figure out what's wrong.
Thank you!
package com.codegym.task.task31.task3111;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
/*
Advanced file search
*/
public class Solution {
public static void main(String[] args) throws IOException {
SearchFileVisitor searchFileVisitor = new SearchFileVisitor();
// searchFileVisitor.setPartOfName("ion");
searchFileVisitor.setPartOfContent("456");
//searchFileVisitor.setMinSize(1);
//searchFileVisitor.setMaxSize(1);
Files.walkFileTree(Paths.get("/Users/baurzhan/Downloads"), searchFileVisitor);
List<Path> foundFiles = searchFileVisitor.getFoundFiles();
for (Path file : foundFiles) {
System.out.println(file);
}
}
}