Meaningless Drivel is fun!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Files" Watch "Files" New topic


Balaji Bang
Ranch Hand

Joined: Apr 23, 2007
Posts: 182

in K&B it is given :

Create a Reader or a Writer or a Stream. Specifically, create a FileReader, a
FileWriter, a PrintWriter, a FileInputStream, or a FileOutputStream.
Whenever you create an instance of one of these classes, you automatically
create a file, unless one already exists, for instance

But the following is giving FileNOtFoundException

This is working fine when I used PrintWriter and FileWriter . Not working only for FileReader . Why please explain...........
Stephen Davies
Ranch Hand

Joined: Jul 23, 2008
Posts: 352
File is not a file on your system. new File("MyFile.txt") is creating a new File Object from where you can call various Methods, to create a file on the system, such as .createNewFile(). If your using Sierra & Bates JAVA 5 see page 431, for more details. The example given there is:

Its a simple method for giving feedback on the existence of files, so;

be a well encapsulated person, don't expose your privates, unless you public void getWife()!
I agree. Here's the link:
subject: Files
It's not a secret anymore!