Should BufferedReader and InputStreamReader be closed explicitly?
I want to read the content of a InputStream into a String : private String readToString(InputStream stream) { return new BufferedReader(new InputStreamReader(stream)) .lines().collect(Collectors.joining("\n")); } The stream comes from java.lang.Process . Question: Do I have to explicitly close any of the InputStream , InputStreamReader or BufferedReader in this case? Sidenote: the linked question is NOT a duplicate, as my question is about HOW to properly close the streams, not how to read the stream to a String! You only need to close the outer wrapper, but don't do that explicitly either way