sink

abstract fun sink(path: Path, append: Boolean = false): RawSink(source)

Returns RawSink to write into a file the path points to. Depending on append value, the file will be overwritten or data will be appened to it. File will be created if it does not exist yet.

How a sink will write the data is implementation-specific and failures caused, for example, by the lack of permissions may not be reported immediately, but postponed until the sink will try to store data.

If path points to a directory, this method will fail with IOException

Parameters

path

the path to a file to write data to.

append

the flag indicating whether the data should be appended to an existing file or it should be overwritten, false by default, meaning the file will be overwritten.

Throws

when it's not possible to open the file for writing.