If given a choice, you should close only DataInputStream . In general, always close the external wrapper thread. The closure will extend inward, and this is the only way to ensure proper behavior in general.
However, if you close the underlying FileInputStream , this will also be enough, because the DataInputStream itself does not receive any system resources.
The most direct answer to your question: no, closing the underlying thread does not close the wrapper thread, but in practice this has nothing to do with the prospects of leaking system resources. Only the stream at the bottom is associated with a real system resource.
source share