Reputation: 13108
Why the StandardOpenOption
parameter is not present at all in the parameter list of this method:
Files.createDirectory(path, FileAttribute<?>)
?
I am talking about the same StandardOpenOption available for writing a file "Files.write(path,byte[],options)" which allows to use the StandardOpenOption.CREATE
which won't give back any exception if the file already exist.
In Files.createFile(..)
and Files.createDirectory()
there is no possibility to insert a StandardOpenOption, so if by mistake I am creating a file which already exist I will get an exception out of it.
Is there any way to insert an option such as StandardOpenOption.CREATE
in the creation of files and directories using Files.createFile(...)
,Files.createDirectory(...);
Upvotes: 1
Views: 649
Reputation: 2775
If you just want the behaviour of CREATE you could use:
Files.createDirectories
If you want to use the options directly you would have to write your own utility method.
Upvotes: 1