I developped an application using spring-boot, I need to read a csv file that contain emails.
this is a snippet how I do:
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;
}
It works when I execute the application using eclipse: run As --> spring-boot app
But when I put the jar into a container docker the method readFile() return an empty set.
I use gradle for build the application
Would you have any ideas ?