Re: referring to file in a relative way
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Thu, 26 Mar 2009 15:50:47 -0700 (PDT)
Hal Rosser wrote:
If you're in the org directory then
File theFile = new File("../../data/info.txt");
Then you can use methods of the File class to get the absolute path, etc if
you need it.
Each dot-dot-slash takes you to the parent directory of wherever you happen
Which if it's close to the root will cause a problem.
Use of parent-directory relative references is not very safe. One
should ensure that all program resources are in a subdirectory of the
working directory so that "dot-dot-slash" is never used.