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:
parent
88bd553009
commit
05c5cd333f
1 changed files with 3 additions and 1 deletions
|
@ -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 =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue