My current application needs to get data from a file to initialize its attributes. It needs to be stored in a file to enable modification to the user.
String strFile = ClassLoader.getSystemResource("myFile.csv").getPath();
if(strFile==null)
throw new Exception("File not find");
BufferedReader br = new BufferedReader(new FileReader(strFile));
//Begin reading file process..
My problem is that strFile
is not null but I have a java.io.FileNotFoundException when br
is initialized, see the following stack:
java.io.FileNotFoundException: C:\Users\TH951S\My%20Documents\Eclipse\Workspace
\My%20App\bin\myFile.csv
(The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
I checked that the file is in the designated path and everything seems correct.
Does anyone knows why this is happening? Or is there another way to get a file when the path is unknown?
Thanks for reading and more for answering,