renameTo
val filesDir = _files.getFilesDir()
val file = _files.buildFile {
setPath(filesDir, "tmp/aaa.txt")
}
file.writeText("hello world", "UTF-8")
val dest = _files.buildFile {
setPath(filesDir, "tmp/bbb.txt")
}
_console.log(file.renameTo(dest))
_console.log(file.exists())
_console.log(dest.exists())
file.delete()
dest.delete()
def filesDir = $files.getFilesDir()
def file = $files.buildFile {
setPath(filesDir, "tmp/aaa.txt")
}
file.writeText("hello world", "UTF-8")
def dest = $files.buildFile {
setPath(filesDir, "tmp/bbb.txt")
}
$console.log(file.renameTo(dest))
$console.log(file.exists())
$console.log(dest.exists())
file.delete()
dest.delete()
let filesDir = $files.getFilesDir()
let file = $files.buildFile((fileBuilder) => {
fileBuilder.setPath(filesDir, "tmp/aaa.txt")
})
file.writeText("hello world", "UTF-8")
let dest = $files.buildFile((fileBuilder) => {
fileBuilder.setPath(filesDir, "tmp/bbb.txt")
})
$console.log(file.renameTo(dest))
$console.log(file.exists())
$console.log(dest.exists())
file.delete()
dest.delete()
local filesDir = _files:getFilesDir()
local file = _files:buildFile(function(fileBuilder)
fileBuilder:setPath(filesDir, "tmp/aaa.txt")
end)
file:writeText("hello world", "UTF-8")
local dest = _files:buildFile(function(fileBuilder)
fileBuilder:setPath(filesDir, "tmp/bbb.txt")
end)
_console:log(file:renameTo(dest))
_console:log(file:exists())
_console:log(dest:exists())
file:delete()
dest:delete()
<?php
$filesDir = $files->getFilesDir();
$file = $files->buildFile(function ($fileBuilder) use ($filesDir) {
$fileBuilder->setPath($filesDir, "tmp/aaa.txt");
});
$file->writeText("hello world", "UTF-8");
$dest = $files->buildFile(function ($fileBuilder) use ($filesDir) {
$fileBuilder->setPath($filesDir, "tmp/bbb.txt");
});
$console->log($file->renameTo($dest));
$console->log($file->exists());
$console->log($dest->exists());
$file->delete();
$dest->delete();
filesDir = _files.getFilesDir()
def fn1(fileBuilder):
fileBuilder.setPath(filesDir, "tmp/aaa.txt")
file = _files.buildFile(fn1)
file.writeText("hello world", "UTF-8")
def fn2(fileBuilder):
fileBuilder.setPath(filesDir, "tmp/bbb.txt")
dest = _files.buildFile(fn2)
_console.log(file.renameTo(dest))
_console.log(file.exists())
_console.log(dest.exists())
file.delete()
dest.delete()
filesDir = $files.getFilesDir()
file = $files.buildFile { |fileBuilder|
fileBuilder.setPath(filesDir, "tmp/aaa.txt")
}
file.writeText("hello world", "UTF-8")
dest = $files.buildFile { |fileBuilder|
fileBuilder.setPath(filesDir, "tmp/bbb.txt")
}
$console.log(file.renameTo(dest))
$console.log(file.exists())
$console.log(dest.exists())
file.delete()
dest.delete()
Last modified: 10 June 2025