问题一
我想把
File root = new File(DashBoardListener.class.getClassLoader().getResource("collectData/").getPath());
改成这样
File root = new File("collectData/application.conf");
为什么不好使
问题二
我的目录结构是这样的
我现在想在DashBoardListener.java
中读取collect中的文件,
请问这段代码怎么修改?
现在这个root 是读取资源目录下的文件
File root = new File(DashBoardListener.class.getClassLoader().getResource("collectData/").getPath());
Arrays
.stream(Objects.requireNonNull(root.listFiles( )))
.filter(file -> file.getName().endsWith("json"))
.map(File::toPath)
.forEach(path -> {
try {
//List<String> lines = Files.readAllLines(path);
//System.out.println("lines = " + lines);
List<String> lines = Files.readAllLines(path);
listFiles.add(lines);
} catch (IOException e) {
e.printStackTrace( );
}
});