• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to close "properly" a stream ?

 
Eric Janssens
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently reading A&T SCJD5.0 book.

In the RMI chapter (I have skip ch3 to ch5), the 2 examples (p187) that focus on object serialization are closing ObjectXxxxStream AND FileXxxxStream.

Is it better to close all the stream one by one OR closing the "external" one is enough. (like in ObjectOuputStream description)


note for the authors: the first finally block cant see oos, the second finally block cant see ois and fis. (p187)
[ March 07, 2006: Message edited by: John Smith ]
 
Eric Janssens
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just add to the title the word properly to give more precision at the subject and perhaps have more reply to my topic
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,

Which book are you referring to? I originally thought you might be referring to the book I wrote with Terry (hence A&T SCJD 5), but my book details are lining up with your questions. According to me, it is chapter 6 (not 5) that discusses RMI, and page 187 is showing part of the DBClient interface.

So if it is the book I wrote with Terry, can you please re-check your references, or provide a little more contextual information so I can try to track the example down?

Regards, Andrew
 
Eric Janssens
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad, it is indeed in your book that I found the example p167 (and not 187 ).

Sorry if you have already discuss that topic in one of the previous chapters. I have skip chapter 3, chapter 4 and chapter 5 to go directly to RMI.

ps: when I am sleepy, I tend to see an 8 when there is only a 6. (Hypermetropia :roll: )
[ March 08, 2006: Message edited by: John Smith ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
Is it better to close all the stream one by one OR closing the "external" one is enough. (like in ObjectOuputStream description)
If you check the source for ObjectOutputStream you will find that it is quite safe to do as Sun demonstrate in the example code. However I personally feel that this can cause confusion for junior programmers, so it should be avoided.
note for the authors: the first finally block cant see oos, the second finally block cant see ois and fis. (p187)
Thanks - I will add that to our errata page.

Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic