PHP
·
发表于 5年以前
·
阅读量:8286
fun copyFileTest() {
val oldFile = File("E:SQLFULL_CHS.iso")
val newFile = File("E:SQLFULL_CHS2.iso")
newFile.deleteOnExit()
newFile.createNewFile()
var c = -1
val buffer = ByteArray(1024 * 1000)
val inputStream = oldFile.inputStream()
val now = System.currentTimeMillis()
while ({ c = inputStream.read(buffer);c }() > 0) {
newFile.appendBytes(buffer.copyOfRange(0, c))
}
println("复制完毕,耗时${(System.currentTimeMillis() - now) / 1000}秒")
}