wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Console behaviour in Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Console behaviour in Java" Watch "Console behaviour in Java" New topic
Author

Console behaviour in Java

Nick Widelec
Ranch Hand

Joined: Feb 28, 2013
Posts: 226

Directly from the official API:

Invoking close() on the objects returned by the reader() and the writer() will not close the underlying stream of those objects.


Why the object would not get close even invoking close()?

Thanks in advance.




OCAJP 7, OCPJP 7
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30353
    
150

Nick,
It looks like Java has a singleton reader. The following code returns true. This means that if the reader were closes, no other code could call it later.



[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Console behaviour in Java