Java遍历某个目录下所有内容,包括子目录,并输出文件绝对路径
@Test
public void test() {
File file = new File("E:\\");//在引号里填写路径
digui(file);
}
public static void digui(File Path) {
File[] file = Path.listFiles();
for (File f : file) {
if (f.isDirectory()) {
if (!(f.listFiles() == null)) {
digui(f);
}
} else {
System.out.println(f.getAbsolutePath());
}
}
}
感觉用多线程是不是更快些,不会,求大佬指教