Reputation: 8400
I'm trying to load a .csv file in a program but for some reason, it's unable to find the file. Where should I place the file?
Console
Upvotes: 0
Views: 22718
Reputation: 1
I tried with all the above mention solution, but it didn't work.. but i went to my project folder and delete the target and tried to compile the project again. it then worked successfully
Upvotes: 0
Reputation: 3247
The file is located in the src directory so in order to access it you should use
src/Elevator.csv
As long as files are located inside your project folder you can access them using relative paths.
For example if a file is located under the Elevator folder then you access the file by using only its filename.
Elevator.csv
A good principle when using additional files in your project is creating separate folders from the ones that the source files are located. So you could create a folder resources under the project folder and place your file there. You can access then the file by using
resources/Elevator.csv
Upvotes: 2
Reputation: 1760
the path which it is trying to read is surely not exact as the path in which that file is actually present.Try printing absolute path of that file and compare it with actual path of your file.
Upvotes: 2
Reputation: 1500525
It looks like the file is in the src
directory... which almost certainly isn't the working directory you're running in.
Options:
src
Class.getResourceAsStream
Upvotes: 7