saveTo

fun BufferedSource.saveTo(file: File)

Saves the content of this BufferedSource to the specified file.

This function creates the parent directories if they don't exist. If an exception occurs during the save process, the source is closed, the file is deleted, and the exception is rethrown.

Parameters

file

The file to save the content to.

Throws

if an error occurs during the save process.


fun BufferedSource.saveTo(stream: OutputStream)

Saves the content of this BufferedSource to the specified OutputStream.

This function uses use to ensure that both the source and the stream are properly closed.

Parameters

stream

The OutputStream to save the content to.