Files.createFile() makes use of newByteChannel(); what if the fs does _not_ support .newByteChannel()?
Alan Bateman
Alan.Bateman at oracle.com
Fri Dec 18 09:00:25 UTC 2015
On 16/12/2015 13:44, Francis Galiegue wrote:
> Hello,
>
> All is in the question really...
>
> The javadoc of .newByteChannel() on the provider says that
> UnsupportedOperationException will be thrown if one OpenOption is not
> supported, but since the filesystems I develop cannot return any
> meaningful form of SeekableByteChannels at all, I always throw
> UnsupportedOperationException...
The original intention was that all providers must implement
newByteChannel and the open options listed in the table. In the
degnerative case then the underlying file system should at least support
reading a file sequentially, or when it's a read-write file system that
is supports writing to a file sequentially. Seeking might mean the
position(long) method fails of course. Also Files.create is specified to
be atomic with respect to other file system operations and that might be
challenge too. It would be good if the javadoc could specify the
absolute minimum but the original intention was not that newByteChannel
always throws UOE.
-Alan.
More information about the nio-dev
mailing list