Hello,
I want to read a file from the current directory.
I did :
BufferedReader myFile = null;
myFile = new BufferedReader(new FileReader("myfile.txt"));
myfile.txt is in the current directory.
after the above code, I get the exception, that the file cannot be openned
(because it is not found).
How can I enforce reading from the current directory ?
Thanks :)
IchBin - 15 Jul 2006 16:14 GMT
> Hello,
> I want to read a file from the current directory.
[quoted text clipped - 10 lines]
>
> Thanks :)
Try looking at the Java Developers Almanac for the IO or NIO packages:
http://javaalmanac.com/egs/java.io/pkg.html
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
nacer - 15 Jul 2006 16:14 GMT
try to use (./myfile.txt)
Eitan M a écrit :
> Hello,
> I want to read a file from the current directory.
[quoted text clipped - 10 lines]
>
> Thanks :)
Chris - 15 Jul 2006 19:43 GMT
> Hello,
> I want to read a file from the current directory.
[quoted text clipped - 10 lines]
>
> Thanks :)
The "current directory" is a slippery notion. It can change depending on
how your app is invoked. You're better off reading the file from a
fixed, known location, for example, a directory which is relative to the
home directory for your app. At start up, determine the home directory,
and then do everything relative to that anchor.