2.3.1 在项目中查找文件
发布时间:2016-01-06 16:00:13
Demo:import java.io.IOException;import java.nio.file.DirectoryStream;import java.nio.file.Files;import java.nio.file.Path;import java.nio.fi ...
Demo:
import java.io.IOException;import java.nio.file.DirectoryStream;import java.nio.file.Files;import java.nio.file.Path;import java.nio.file.Paths;/**在目录中查找文件:用模式匹配过滤dir项目中所有的.properties文件; * @author jinxing * @DirectoryStream DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.properties") * 过滤流中用到的模式匹配称为glob模式匹配——*.properties */public class PathFindGlob { public static void main(String[] args) { // 提前准备好的目录及其中的三个文件:log4j. Path dir = Paths.get("/Users/jinxing/Documents/pathtest/path1"); try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, "*.properties")) { for (Path entry: stream) { System.out.println(entry.getFileName()); } } catch (IOException e) { System.out.println(e.getMessage()); } }}
原标题:2.3.1 在项目中查找文件
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。
法国电商市场:https://www.goluckyvip.com/tag/11056.html
谷歌关键词:https://www.goluckyvip.com/tag/11057.html
C88文件:https://www.goluckyvip.com/tag/11058.html
引流技巧:https://www.goluckyvip.com/tag/11059.html
致欧科技:https://www.goluckyvip.com/tag/1106.html
中美贸易站:https://www.goluckyvip.com/tag/11060.html
三亚有哪些酒店值得入住?:https://www.vstour.cn/a/366173.html
零售晚报:丽人丽妆2023年扭亏为盈 玉容初、美壹堂等自有品牌增速超40% :https://www.kjdsnews.com/a/1836649.html