2019年3月10日日曜日

Kotlin メモ : File.outputStream(), OutputStream.writer()

fun File.outputStream(): FileOutputStream
fun OutputStream.writer(charset: Charset = Charsets.UTF_8): OutputStreamWriter
fun File.writer(charset: Charset = Charsets.UTF_8): OutputStreamWriter

val writer = OutputStreamWriter(FileOutputStream(file), charset) writer.write(...) writer.close() file.outputStream() .writer(charset) .use { it.write(...) } file.writer(charset) .use { it.write(...) }