Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Does closing a stream, close the enclosed stream as well?

 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I had a trivial question. Does closing a stream, close the enclosed stream as well?
For e.g., if I have a BufferedInputStream which encloses a FileInputStream, then does closing BufferedInputStream take care of closing FileInputStream as well?
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on the InputStream class*, but in general: yes.

* you can subclass FilterInputStream to make close do nothing.
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic