1 import java.io.File;
2
3 /**
4 * @Author: heq
5 * @Date: 2020/6/23 20:51
6 */
7 public class Test {
8 public static void main(String[] args) {
9 File file = new File("C:");//查找的盘符
10 heq(file);
11 }
12
13 public static void heq(File file) {
14 File[] files = file.listFiles();
15 if (files != null) {
16 for (File file1 : files) {
17 if (file1.isFile() && file1.getName().endsWith(".wmv")) {//wmv查找的格式
18 System.out.println(file1.getName());
19 }
20 if (file1.isDirectory()) {
21 heq(file1);
22 }
23 }
24 }
25 }
26 }
原文
http://www.cnblogs.com/hqjava/p/13192720.html