• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

How to close "properly" a stream ?

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic