0
在下面的代码片段中,如何保留找到的(路径)值并将其返回给调用该方法的类?在递归方法调用之间保留值
public void searchFile(Path searchFrom, String match) throws IOException {
try(DirectoryStream<Path> SearchResult = Files.newDirectoryStream(searchFrom)) {
for(Path check : SearchResult) {
if(!Files.isDirectory(check) && check.toString().contains(match)) {
System.out.println(check.toString());
} else if(Files.isDirectory(check)) {
searchFile(check, match);
}
}
}
}
我们的目标是能够找到(文件)的路径递归目录树中,而这些返回谁调用的类/调用的方法。
是否期望为了有在结果的一个或多个发现路径? – aglassman