Short question,
I saw in some old code where a ByteArrayInputStream
was created like:
new BufferedReader(new InputStreamReader(new ByteArrayInputStream(somebytes)));
And then the BufferedReader
is used to read out somebytes
line by line.
All working fine, but I noticed that the BufferedReader
is never closed.
This is all working in a long running websphere application, the somebytes
are not terrible big (200k most), it is only invoked a few times a week and we're not experiencing any apparent memory leaks. So I expect that all the objects are successfully garbage collected.
I always (once) learned that input/output streams need to be closed, in a finally
statement. Are ByteStreams
the exception to this rule?
kind regards Jeroen.