RFR: 8017513: Support for closeable streams
Alan Bateman
Alan.Bateman at oracle.com
Thu Aug 29 09:15:00 UTC 2013
On 29/08/2013 09:51, Paul Sandoz wrote:
> On Aug 29, 2013, at 8:58 AM, Alan Bateman<Alan.Bateman at oracle.com> wrote:
>
>> :
>>
>> I think I mentioned this previously but in the Files.list/walk/etc. methods where you close the resource (on error|runtimeexception) then it's probably best to catch the IOException and add it as a suppressed exception.
>>
> Can TWR be used?
>
> try (DirectoryStream<Path> ds = Files.newDirectoryStream(dir) {
> ...
> }
>
It should be only closed for the error/exception case (as the Stream
will keep the directory open).
Henry - Paul's comment reminds of that "one or more" doesn't need to the
javadoc for Files.lines as it only opens one directory.
-Alan.
More information about the core-libs-dev
mailing list