Hello friends,
I want to read a file from a directory which is in parallel to the current directory.
For example, consider the following directory structure: -
In
Tester.java i want to read the
text.txt file which is actually in a directory parallel to the enclosing directory of Tester class.
I am trying to access the file by giving the path argument to the
File class as
... but i get FileNotFoundException ... shouldn't the
string argument that i provided go one level up( since i have specified
two dots as we do while accessing directory in Linux) and then into the resources directory to access the
test.txt ?
I want to access the the
test.txt relative to the
Tester.java ... because i can give the entire
src folder to my friend ... he can put in any directory and try to run it without any change to the code!
How do i access the file relatively ? ... is my way of accessing the file relatively incorrect ?
P.S. By the way i am using Windows Vista Home Basic Edition OS and
Java 1.6
Thanks and regards
Omkar Patkar