In my java program, I am trying to save a .csv
file into my data folder located in the same folder as the main jar
file.
Previously, when I used to run my programs on Windows machines, my relative path was: data\\foo.csv
. When I tried the same on Linux, it created and saved the file with name: data\\foo.csv
in the root directory.
Then I tried to set the path to data/foo.csv
and I am getting this error:
java.io.FileNotFoundException: data/04-12-2015.csv (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileWriter.<init>(Unknown Source)
at main.Main.saveResultsToFile(Main.java:121)
at main.Main.main(Main.java:92)
I have set permissions of the directory to 777 (granted all permissions to everyone).
Code responsible for creating and saving the file:
String fileName = "data/foo.csv"
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
Edit:
The permission is not recursive, if that changes anything. Only the data
folder has 777 permission.