kotlin.io.java.io.File.copyTo
copyTo
fun File.copyTo( target: File, overwrite: Boolean = false, bufferSize: Int = DEFAULT_BUFFER_SIZE ): File
Platform and version requirements: JVM
Copies this file to the given target file.
If some directories on a way to the target are missing, then they will be created. If the target file already exists, this function will fail unless overwrite argument is set to true
.
When overwrite is true
and target is a directory, it is replaced only if it is empty.
If this file is a directory, it is copied without its content, i.e. an empty target directory is created. If you want to copy directory including its contents, use copyRecursively.
Parameters
overwrite
- true
if destination overwrite is allowed.
bufferSize
- the buffer size to use when copying.
Exceptions
NoSuchFileException
- if the source file doesn't exist.
FileAlreadyExistsException
- if the destination file already exists and 'rewrite' argument is set to false
.
IOException
- if any errors occur while copying.
Return the target file.
© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/java.io.-file/copy-to.html