Files.walk is one of the streams that I should close, however, how do I close the stream in code like below? Is the code below valid or do I need to rewrite it so I have access to the stream to close it?
List<Path> filesList = Files.walk(Paths.get(path)).filter(Files::isRegularFile ).collect(Collectors.toList());