File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Will FileReader create a new file? 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 "Will FileReader create a new file?" Watch "Will FileReader create a new file?" New topic

Will FileReader create a new file?

Benjamin Samuel
Ranch Hand

Joined: Dec 15, 2006
Posts: 33
K&B Book states that

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...

But when I create an instance of FileReader, i get a FileNotFoundException if the file does not exist before. Code follows:

Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
No, this is a bug in the book. Search this forum for topics that discuss this.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: Will FileReader create a new file?
It's not a secret anymore!