List of utility methods to do File Backup
void | saveBackup(File file, int backups, String backupPrefix, String backupSuffix, String backupDirectory) Saves a backup (optionally numbered) of a file. if (backupPrefix == null) backupPrefix = ""; if (backupSuffix == null) backupSuffix = ""; String name = file.getName(); if (backups == 1) { file.renameTo(new File(backupDirectory, backupPrefix + name + backupSuffix)); else { new File(backupDirectory, backupPrefix + name + backupSuffix + backups + backupSuffix).delete(); for (int i = backups - 1; i > 0; i--) { File backup = new File(backupDirectory, backupPrefix + name + backupSuffix + i + backupSuffix); backup.renameTo( new File(backupDirectory, backupPrefix + name + backupSuffix + (i + 1) + backupSuffix)); file.renameTo(new File(backupDirectory, backupPrefix + name + backupSuffix + "1" + backupSuffix)); |