1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Close the OutputStream when done.

This commit is contained in:
Cedric Beust 2015-11-19 19:56:47 -08:00
parent 88bd553009
commit 05c5cd333f

View file

@ -39,7 +39,9 @@ class Kurl @Inject constructor(@Assisted val url: String) {
fun toOutputStream(os: OutputStream, progress: (Long) -> Unit) = copy(connection.inputStream, os, progress) fun toOutputStream(os: OutputStream, progress: (Long) -> Unit) = copy(connection.inputStream, os, progress)
fun toFile(file: File, progress: (Long) -> Unit = {}) = toOutputStream(FileOutputStream(file), progress) fun toFile(file: File, progress: (Long) -> Unit = {}) = FileOutputStream(file).use {
toOutputStream(it, progress)
}
private fun copy(from: InputStream, to: OutputStream, progress: (Long) -> Unit = {}) : Long { private fun copy(from: InputStream, to: OutputStream, progress: (Long) -> Unit = {}) : Long {
val estimate = val estimate =