Reputation: 1025
I started working with some files, something easy.
I read that the File
class support relative paths, so I tried something like:
File file_bg = new File("data\\bg.png");
if(file_bg.exists())
flag_bg = true;
Ok, now, making some debugging I noticed that every File variable have as parent path the same path where the IDE is, instead of the path where my project is.
Is it a common behavior or I have to set up something before starting the sketch? Is it equal for java IDEs like NetBeans?
One more question, there is a way to keep a String
variable in memory that contains the path of my .pde
file?
Thanks a lot for the interest, waiting a response!
Upvotes: 0
Views: 237
Reputation: 2800
You don't need to store a string with that directory, Processing can give it to you with sketchPath()
and dataPath()
... Not particularly odd, google's first result for "processing sketch path" returns this
thus:
File file_bg = new File(dataPath("bg.png"));
Upvotes: 2