1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| package sousuo; import java.*; import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.stream.Stream;
public class FileListGenerator { public void start() { File file = new File("C:\\Users\\pc\\Desktop\\待测文件夹"); search(file); } public void search(File file) { if (file.isDirectory()) { File[] listFiles = file.listFiles(); for (File f : listFiles) { search(f); } } if (file.getName().endsWith(".ppt")) { System.out.println(file); } } public static void main(String []args){ //Scanner a=new Scanner(System.in); FileListGenerator me=new FileListGenerator(); me.start(); } }
|