This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I found something wrong form K&B chapter 6 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 "I found something wrong form K&B chapter 6" Watch "I found something wrong form K&B chapter 6" New topic

I found something wrong form K&B chapter 6

Jack Crifer

Joined: May 18, 2008
Posts: 29
In Working with Files and Directories

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

I think just like FileInputStream,FileReader ,those INPUT funtion never created any file which is not exist.
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Be careful when putting something like this up, I have done that many times and most usually it results in wasted time. If you can show us the code that fails to createFile(), we can run the tests that duplicate the failure.

Be sure to run it several times before showing us.

"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

Given just the quote you've shown, without any context, you are absolutely right. Constructing a FileReader or FileInputStream will never create a new file. Check the errata page for the book -- this is most likely a known issue.

[Jess in Action][AskingGoodQuestions]
Jack Crifer

Joined: May 18, 2008
Posts: 29
Hi,Ernest. where I can get the errata table for the book.

Best Regards.
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
You can find the link to the errata page at the top of this very forum

Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: I found something wrong form K&B chapter 6
It's not a secret anymore!