public OutputStream newOutputStream (Path path, OpenOption… options) throws IOException

Opens or creates a file, returning an output stream that may be used to write bytes to the file. This method works in exactly the manner specified by the Files.newOutputStream method.

The default implementation of this method opens a channel to the file as if by invoking the newByteChannel method and constructs a stream that writes bytes to the channel. This method should be overridden where appropriate.

path     the path to the file to open or create
options     options specifying how the file is opened

Returns:  a new output stream

IllegalArgumentException     if options contains an invalid combination of options
UnsupportedOperationException     if an unsupported option is specified
IOException     if an I/O error occurs
SecurityException     In the case of the default provider, and a security manager is installed, the checkWrite method is invoked to check write access to the file. The checkDelete method is invoked to check delete access if the file is opened with the DELETE_ON_CLOSE option.