Consider the typical code:
try {
FileReader fr = new FileReader("42.txt");
BufferedReader br = new BufferedReader(fr);
} finally {
//??
}
Should close
in the finally
clause be called for both or them or is it sufficient to close
only one reader (if so, then which one?).
I would think that it should be sufficient to close only the most external wrapper, because with the following code that utilises try with resources only br
will be closed:
try (BufferedReader br = new BufferedReader(new FileReader("42.txt"))) {
}