problem using File or URL ....

i completly formatted my computer , before i did the format for instance whenever i instantiate a

File f =new File("testInput.txt");

that worked and i could do ouputstream or what ever but now i have to put the complete path .e.g

File f =new File("c:\\test.txt");

please help...

[428 byte] By [fouadka] at [2007-10-3 2:47:34]
# 1
When you use only the file name the file should exist in the working directory of the program. (BAsically what you are giving is the relative path)
LRMKa at 2007-7-14 20:36:21 > top of Java-index,Java Essentials,Java Programming...
# 2
the thing is that the text file is in the same directory...it used to work now it doesnt...it have to work coz putting the complete path reduce java's power of platform independence...what i mean is that the program wont work for instance on linux...please help...
fouadka at 2007-7-14 20:36:21 > top of Java-index,Java Essentials,Java Programming...
# 3

>> coz putting the complete path reduce java's power of platform independence

no, there is no danger. this phenomenon is completely local to

just you.

File file = new File("file.txt");

Always works. And it always find the file "file.txt" in the working directory.

Try this, print:

new File(".").toAbsolutePath();

And make sure your working directory is what you think it is.

TuringPesta at 2007-7-14 20:36:21 > top of Java-index,Java Essentials,Java Programming...
# 4
Your case the "Same Directory" seems not the working directory.
LRMKa at 2007-7-14 20:36:21 > top of Java-index,Java Essentials,Java Programming...