Does closing Datainputstream always close Inputstream?

Asked

Viewed 67 times

0

I need to temporarily use one Datainputstream with an inputStream of a socket.

I need to use close-up on Datainputstream? And if I use I’d be closing the socket inputStream too ?

1 answer

2


If you close Datainputstream, it will close the stream you passed in your constructor (in your case, the socket inputStream).

Of the documentation of Datainputstream, in the section methods inherited from the Filterinputstream class has the link to the method close. Clicking on it the description says that it calls the close in Inner stream ("This method Simply performs in.close().").

  • So I should just ignore it , and not close it?

  • 1

    It depends; when you are no longer using Datainputstream, do you still want to use the socket inputStream? If so, then you should not close it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.