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(); + } }