I have a project in java, in which I read in some csv-data. I have to type in the specific path. Now I would like to send this project to someone else, but he should not have to change the path information. He should be able to run the project, without changing anything in the code.
I have already put the csv-data into my source-file but I get an exception, when trying to use this path.
BufferedReader in = new BufferedReader(new FileReader("text.csv"));
Exception while reading csv file: java.io.FileNotFoundException: text.csv (No such file or directory)
I am using as IDE eclipse.
Put the file in root of your Java source folder and then make sure that its getting complied to your classes or bin or target folder(where all your compiled classes are going). Once done, then change your code as below:
When you package your project for distribution, make sure your
text.csvis packaged in the same folder i.e. root of classes folders.