OpenOptions on newInputStream.
Alan Bateman
Alan.Bateman at oracle.com
Tue Sep 6 13:02:18 PDT 2011
Salter, Thomas A wrote:
>
> FileSystemProvider.newInputStream disallows any OpenOption other than
> StandardOpenOption.Read. Thus it can't be used to specify a
> LinkOption or an implementation-defined extension. Was this really
> the intention?
>
This seems to be an oversight, it should allow any open option except
WRITE and APPEND through.
>
>
> FileSystemProvider.newOutputStream, on the other hand, explicitly
> disallows StandardOpenOption.Read but allows everything else.
>
>
>
> I can fix this by overriding the FileSystemProvider implementation in
> my provider, but it doesn't seem like I should have to do that.
>
>
>
>
>
> On a related note, there seems to be a lack of completeness with the
> various shortcuts for opening files:
>
> 1. Files.newBufferedReader does not take open options, but
> Files.newBufferedWriter does.
>
These methods are intended for simple/common cases. In that context the
OpenOption[] parameter is not interested. We had to include it in
newBufferedWriter because appending is common. More advanced needs can
of course use newByteChannel and wrap the channel as needed.
> 2. Files.newByteChannel takes a FileAttribute parameter, but
> Files.newBufferedWriter and newOutputStream do not, even though all
> can create files.
>
The expectation is that it should be rare to need to specify initial
attributes and so only the more advanced methods have the
FileAttribute[] parameter.
-Alan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-discuss/attachments/20110906/c2795c68/attachment.html
More information about the nio-discuss
mailing list