将目录的全部内容列为链接、文件、子目录和隐藏文件
/** * 时代Java公众号 - N o w J a v a . c o m 提 供 **/ import java.io.IOException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path path = Paths.get("C:/folder1/folder2/folder4"); // no filter applied System.out.println("\nNo filter applied:"); try (DirectoryStream<Path> ds = Files.newDirectoryStream(path)) { for (Path file : ds) { System.o