Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

read from current directory

Thread view: 
Eitan M - 15 Jul 2006 15:53 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.