Path.newOutputStream((Set<? extends OpenOption> options, FileAttribute<?>... attrs) ?
Alan Bateman
Alan.Bateman at Sun.COM
Tue Nov 17 09:11:23 PST 2009
Vince Bonfanti wrote:
> Because Path.newOutputStream can create a new file, shouldn't there be
> an overload that accepts FileAttribute<?> arguments?
>
> I'm writing code that needs to set filesystem-specific attributes
> whenever a new file is created, but can't do this when creating a file
> with Path.newOutputStream.
>
> Vince
It could be added if really needed - there is an assumption that it
won't be too common to want to set the initial attributes. At least with
the default provider, it is mainly for security related attributes.
Alternatives to consider would be to use createFile or use a channel, eg:
OutputStream out = file.createFile(attr).newOutputStream();
OutputStream out = Channels
.newOutputStream(file.newByteChannel(EnumSet.of(CREATE_NEW,WRITE),
attr));
-Alan
More information about the nio-discuss
mailing list