我使用spring-boot开发了一个应用程序,我需要读取包含电子邮件的csv文件。无法读取jar文件中的文件
这是一个片段我该怎么做:由于运行 - >春季启动应用
但是,当我把罐子到:
public Set<String> readFile() {
Set<String> setOfEmails = new HashSet<String>();
try {
ClassPathResource cl = new ClassPathResource("myFile.csv");
File file = cl.getFile();
Stream<String> stream = Files.lines(Paths.get(file.getPath()));
setOfEmails = stream.collect(Collectors.toSet());
} catch (IOException e) {
logger.error("file error " + e.getMessage());
}
return setOfEmails;
}
它,当我使用eclipse执行应用程序的工作原理容器docker的方法readFile()返回一个空集。
我使用gradle构建应用程序
你有什么想法吗?
问候
谢谢@Stephen C.它适用于我 – Victor