Considering Java code below:
void test(InputStream inputStream) {
DataInputStream dataInputStream = new DataInputStream(inputStream);
return;
}
when test
method returns, dataInputStream will (sometime) be garbage collected. Does DataInputStream closes inner stream in its finalizer?
I failed to find any explicit statement if it does or not. Is there any official documentation about behavior? Can please you point if there is one?
Thanks.
Edit: I am not asking if closing DataInputStream closes inner stream too. I am asking what if I don't close and outer stream is garbage collected while inner still has references to it hence alive.