can file.renameTo replace a existing file?

Viewed 16769
// File (or directory) to be moved
File file = new File("filename");

// Destination directory
File dir = new File("directoryname");

// Move file to new directory
boolean success = file.renameTo(new File(dir, file.getName()));
if (!success) {
    // File was not successfully moved
    //can it be because file with file name already exists in destination?
}

If the file with name 'filename' already exists in the destination will it be replaced with a new one?

3 Answers
Related