Does collect operation on Stream close the stream and underlying resources?
Does below code need to be wrapped in try-with-resources to make sure underlying file is closed? List<String> rows = Files.lines(inputFilePath).collect(Collectors.toList()); As the javadoc of the overloaded Files#lines(Path, Charset) method states The returned stream encapsulates a Reader . If timely disposal of file system resources is required, the try-with-resources construct should be used to ensure that the stream's close method is invoked after the stream operations are completed. So yes, wrap the Stream returned by lines in a try-with-resources statement. (Or close it appropriately.)