List of utility methods to do Rename File
void | renameTo(File from, File to, boolean deleteDestination) rename To if (deleteDestination) { deleteIfExists(to); if (!from.renameTo(to)) { throw new IOException(); |
void | renameTo(File fromFile, File toFile) rename a file to another file and throw runtime exception if not ok if (!fromFile.renameTo(toFile)) { throw new RuntimeException("Cannot rename file: '" + fromFile.getAbsolutePath() + "', to file: '" + toFile.getAbsolutePath() + "'"); |
boolean | renameTo(File orig, File dest) rename To if (orig.equals(dest)) throw new IllegalArgumentException("Huh? the two file descriptors are the same!"); if (!orig.exists()) { throw new IllegalArgumentException("Original doesn't exist!"); if (!orig.renameTo(dest)) { if (!dest.delete()) { if (dest.exists()) { ... |
File | renameTo(File source, String newName) Rename the file specified to the new name specified in parameters. if (!source.exists()) return null; String parentPath = source.getParent() == null ? "" : source.getParent(); File target = new File(parentPath, newName); boolean ret = source.renameTo(target); return ret ? target : null; |
boolean | renameTo(final File srcFile, final File dstfile) Rename File in privileged mode. return new Boolean(srcFile.renameTo(dstfile)); |
boolean | renameTo(String fileName, String targetFileName) Renames a file with new file name. File current = new File(fileName); File newF = new File(targetFileName); if (!current.exists()) { throw new IOException("File [" + fileName + "] does not exits"); if (newF.exists()) { newF.delete(); return current.renameTo(new File(targetFileName)); |
boolean | renameToBackupName(File file) rename To Backup Name return file.renameTo(backupFile(file));
|
void | renameToBackupName(File file) rename To Backup Name File backupFile = new File(file.getParentFile(), file.getName() + "~"); if (backupFile.exists()) { boolean deleted = backupFile.delete(); if (!deleted) { throw new IOException("Cannot delete backup file " + backupFile); boolean renamed = file.renameTo(backupFile); ... |
File | renameToNextSequencedFile(String srcfile, String destfolder, String prefix, String suffix) rename To Next Sequenced File synchronized (renameToNextSequencedFileLock) { File src = new File(srcfile); File dest = null; int count = 0; if (destfolder == null) { if (src.getParent() != null) destfolder = src.getAbsoluteFile().getParent(); else ... |
File | renameToTempDir(File file, String newName) rename To Temp Dir return renameToTempDir(file, newName, null, null, 1);
|