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 writer() method of Console 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 "writer() method of Console " Watch "writer() method of Console " New topic

writer() method of Console

Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

From Niko's blog

I thought that the last line will give a runtime error, since the Writer associated with console is closed. But it goes on to print "Hello".

Could anybody explain this please?


"A problem well stated is a problem half solved.” - Charles F. Kettering
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

The API for the class says : Invoking close() on the objects returned by the reader() and the writer() will not close the underlying stream of those objects.

[My Blog]
All roads lead to JavaRanch
Nidhi Sar
Ranch Hand

Joined: Oct 19, 2009
Posts: 252

Interesting. Thanks, Christophe!
I agree. Here's the link:
subject: writer() method of Console
It's not a secret anymore!