aspose file tools*
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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "writer() method of Console " Watch "writer() method of Console " New topic
Author

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?

Thanks!


"A problem well stated is a problem half solved.” - Charles F. Kettering
SCJP 6, OCPJWCD
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

The API for the java.io.Console 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: http://aspose.com/file-tools
 
subject: writer() method of Console