try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(root, path))) { xxxxx }catch{ xxxxx }
和平常见的不一样
这种情况的()中的代码一般放的是对资源的申请,如果{}中的代码出项了异常,()中的资源就会被关闭
对文件的操作比较常见。