Close DataInputStream always closes InputStream?

0

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

Do I need to use close in DataInputStream ? And if I use it would I be closing the inputStream of the socket as well?

    
asked by anonymous 15.03.2016 / 19:40

1 answer

2

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

From the DataInputStream documentation , in the Methods section inherited from the FilterInputStream class has the close . By clicking on it the description speaks that it calls the close in the inner stream "This method simply performs in.close ().")     

15.03.2016 / 20:00