Stream API 遍历文件
@Test
public void test2() throws IOException {
Stream<Path> list = Files.list(Paths.get("C:\Users\82341\Desktop\ps"));
list.forEach(this::list);
}
public void list(Path path) {
if (Files.isDirectory(path)) {
try {
Files.list(path).forEach(System.out::println);
} catch (IOException e) {
e.printStackTrace();
}
}else{
System.out.println(path);
}
}