fun copyFileTest() {
val oldFile = File(filesDir.path+"/oldfile.txt")//没有此文件可以创建一个,也可以根据自己情况加个判断看有没有
val newFile = File(filesDir.path+"/newfile.txt")//没有此文件可以创建一个,也可以根据自己情况加个判断看有没有
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}秒")