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?
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?
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 ().")