public class GiguiTest {
public static void main(String[] args) {
File file = new File("D:\\QQ消息");
// "D:/" 这样写不转义也可以
//不能是整个盘
DiguiFindFile(file);
}
|
public static void DiguiFindFile(File file) {
File[] listFiles = file.listFiles();
for (File file2 : listFiles) {
//for (int i=0;i< istFiles.length;++i) {
if (file2.isDirectory()) {
DiguiFindFile(file2);
} else {
if (file2.getName().endsWith(".jpg")) {
System.out.println(file2.getAbsolutePath());
}
}
}
}
}
|
Java——使用File类递归遍历指定路劲下的所有文件
猜你喜欢
转载自www.cnblogs.com/meihao1203/p/9181882.html
今日推荐
周排行