fun File.copyRecursively( target: File, overwrite: Boolean = false, onError: (File, IOException) -> OnErrorAction = { file, exception -> throw exception } ): Boolean
Platform and version requirements: JVM
Copies this file with all its children to the specified destination target path. If some directories on the way to the destination are missing, then they will be created.
If any errors occur during the copying, then further actions will depend on the result of the call to onError(File, IOException)
function, that will be called with arguments, specifying the file that caused the error and the exception itself. By default this function rethrows exceptions. Exceptions that can be passed to the onError
function: NoSuchFileException - if there was an attempt to copy a non-existent file FileAlreadyExistsException - if there is a conflict AccessDeniedException - if there was an attempt to open a directory that didn't succeed. IOException - if some problems occur when copying.
overwrite
- true
if it is allowed to overwrite existing destination files and directories.
Return
false
if the copying was terminated, true
otherwise.
Note that if this function fails, then partial copying may have taken place.
© 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-recursively.html