I have a problem that might be the same one. I have written an experiment that I run several times for each set of parameter values. I want to save them with the same name apart from an appended serial number, such as Sp1Sep2_1.csv, Sp1Sep2_2.csv, ... I may want to save the files in a folder chosen by me or in the default "data" folder in the folder with my source code. I check for the next name in the series by looking to see if Sp1Sep2_1.csv exists, then _2 ...
- If I have selected a folder from a dialogue, all is well. But if I just give a relative filename, it will see if the file exists in the "data" folder and then write the file to to parent of the "data" folder. The relevant code lines are myFileBase = "Sp"+ival+"Sep"+isep+"Bgs"+nbg+"_";
if (defaultFolder == true || folderChosen == false) {
local = true;
}
else {
local = false;
}
//Check whether the file exists, and incremenet the serial number if it does
for (int i = 1; i < 11; i++) {
if (local == true) {
myFile = myFileBase+i+".csv";
}
else {
myFile = dataFolder+myFileBase+i+".csv";
}
// println ("trying myFile = "+myFile);
f = dataFile(myFile);
// println("Looking for file "+f);
if (f.exists() == false) {
println("Did not find "+myFile);
break;
}
.....
followed later by
saveStrings(myFile, lines);
"myFile" for f.exists is in "data" but myFile for saveStrings is not. I've looked for some reference to "dataFile" both in the language reference and in the javadoc for java.io.file with no luck, because I suspect that might be where the spurious "data" gets added to the path. Is that where it is? and if so, is there another way to find out whether the file exists in the same place to which I write when I just want to use the default data folder? It's a bit of a kludge to look for the file in one place and then add "data/" before the file name for writing. This all seemed to work before the b8 upgrade, though I may be wrong, as I have made other coding changes that shouldn't but may have affected the file operations.