moveTo

Platform and version requirements: JVM (1.5), JRE7 (1.5)
fun Path.moveTo(
    target: Path, 
    vararg options: CopyOption
): Path

Moves or renames the file located by this path to the target path.

Parameters

options - options specifying how the move should be done, see StandardCopyOption, LinkOption.

Exceptions

FileAlreadyExistsException - if the target file exists but cannot be replaced because the StandardCopyOption.REPLACE_EXISTING option is not specified (optional specific exception).

DirectoryNotEmptyException - the StandardCopyOption.REPLACE_EXISTING option is specified but the file cannot be replaced because it is a non-empty directory, or the source is a non-empty directory containing entries that would be required to be moved (optional specific exception).

See Also

Files.move

Platform and version requirements: JVM (1.5), JRE7 (1.5)
fun Path.moveTo(
    target: Path, 
    overwrite: Boolean = false
): Path

Moves or renames the file located by this path to the target path.

Parameters

overwrite - allows to overwrite the target if it already exists.

Exceptions

FileAlreadyExistsException - if the target file exists but cannot be replaced because the overwrite = true option is not specified (optional specific exception).

DirectoryNotEmptyException - the overwrite = true option is specified but the file cannot be replaced because it is a non-empty directory, or the source is a non-empty directory containing entries that would be required to be moved (optional specific exception).

See Also

Files.move

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/move-to.html