From 43989e14617e562b2019f59074a99891cb123133 Mon Sep 17 00:00:00 2001 From: sltap Date: Mon, 22 Aug 2022 09:16:25 -0400 Subject: [PATCH] 14.5 --- src/main/java/com/github/hcsp/polymorphism/FileFilter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/hcsp/polymorphism/FileFilter.java b/src/main/java/com/github/hcsp/polymorphism/FileFilter.java index c0dfa2a..903fe91 100644 --- a/src/main/java/com/github/hcsp/polymorphism/FileFilter.java +++ b/src/main/java/com/github/hcsp/polymorphism/FileFilter.java @@ -1,6 +1,7 @@ package com.github.hcsp.polymorphism; import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; @@ -24,5 +25,9 @@ public static void main(String[] args) throws IOException { * @param extension 要过滤的文件扩展名,例如 .txt * @return 所有该文件夹(及其后代子文件夹中)匹配指定扩展名的文件的名字 */ - public static List filter(Path rootDirectory, String extension) throws IOException {} + public static List filter(Path rootDirectory, String extension) throws IOException { + MyFileVisitor resultat=new MyFileVisitor(extension); + Files.walkFileTree(rootDirectory,resultat); + return resultat.getNoms_filtres(); + } }