FileNotFoundException when running ExecuteAround main method in chap3 package
RickyGo opened this issue · 2 comments
RickyGo commented
I think that replace "lambdasinaction/chap3/data.txt"
with ExecuteAround.class.getResource("/lambdasinaction/chap3/data.txt").getPath()
should solve the problem.
Deleted user commented
Swap out new FileReader("lambdasinaction/chap3/data.txt")
with new InputStreamReader(ClassLoader.getSystemResourceAsStream("lambdasinaction/chap3/data.txt"))
and it works correctly.
And this worked for me too.
Files.newBufferedReader(Paths.get(ExecuteAround.class.getResource("/lambdasinaction/chap3/data.txt").getPath()))
felipealvesgnu commented
You can swap for :
try (BufferedReader br = new BufferedReader(new FileReader("src/main/resources/lambdasinaction/chap3/data.txt"))) {
with absolute path.