> On Nov 17, 2016, at 9:33 AM, Bradford Wetmore <[email protected]>
> wrote:
>
> try (PrintWriter out = new PrintWriter(FILENAME)) {
> Files.lines(path)
> .filter(x -> !x.trim().startsWith("crypto.policy"))
> .forEach(out::println);
> }
Not very sure. Although IMHO a terminate method like forEach *should* close the
stream, the spec has not said so:
* <p>Streams have a {@link #close()} method and implement {@link AutoCloseable}.
* Operating on a stream after it has been closed will throw {@link
IllegalStateException}.
* Most stream instances do not actually need to be closed after use, as they
* are backed by collections, arrays, or generating functions, which require no
* special resource management. Generally, only streams whose source is an IO
channel,
* such as those returned by {@link Files#lines(Path)}, will require closing. If
a
* stream does require closing, it must be opened as a resource within a
try-with-resources
* statement or similar control structure to ensure that it is closed promptly
after its
* operations have completed.
I know you use Windows, so if you haven't seen any test failure, maybe it's
safe.
Thanks
Max