Refactor: Use Kotlin DEFAULT_BUFFER_SIZE

This commit is contained in:
Hai Zhang 2024-02-11 21:17:37 -08:00
parent bced5e6fb0
commit 79114bfefe

View File

@ -10,8 +10,6 @@ import java.io.InputStream
import java.io.InterruptedIOException
import java.io.OutputStream
private const val BUFFER_SIZE = 8 * 1024
// Can handle ProgressCopyOption.
@Throws(IOException::class)
fun InputStream.copyTo(
@ -19,7 +17,7 @@ fun InputStream.copyTo(
intervalMillis: Long,
listener: ((Long) -> Unit)?
) {
val buffer = ByteArray(BUFFER_SIZE)
val buffer = ByteArray(DEFAULT_BUFFER_SIZE)
var lastProgressMillis = System.currentTimeMillis()
var copiedSize = 0L
while (true) {