Package com.sun.javatest.util
Class BackupUtil
java.lang.Object
com.sun.javatest.util.BackupUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
backupAllSubdirs
(File dir, int maxBackups) Backups all found "layers" of subdirs.static void
backupContents
(File dir, int maxBackups) backups all files in the directory.static void
This method created to backup dirs.static int
backupFile
(File file, int maxBackups) Performs backup of file.static boolean
static boolean
-
Constructor Details
-
BackupUtil
public BackupUtil()Creates a new instance of BackupUtil
-
-
Method Details
-
backupFile
Performs backup of file. Searches for all files with the same name + "~i~"(such names we use for backupped files). For each backup it increase it's number for 1 (older backups has higher numbers). Then checks, if there more backups, then maxBackups allows, and remove superfluous old backups.- Parameters:
file
- File to backupmaxBackups
- Maximum number of allowed backups- Returns:
- number of backup levels after finishing operation.
-
backupDir
This method created to backup dirs. It just renames directories, not content of this directories. Renaming mechanism is the same, as for backupFile(). If dir is empty, returns. If parameter is not dir, returns. -
backupAllSubdirs
Backups all found "layers" of subdirs. Subdirs have the same layer, if suffixes of their names are the same (suffix has format ~ + int number + ~)- Parameters:
dir
- root dir where layers situatedmaxBackups
- max allowed time to backup
-
backupContents
backups all files in the directory. No rename of directory. Not - recursive -
checkForInteger
- Parameters:
s
- Checks, if this String represents integer number- Returns:
- true, if if this String represents integer number, false otherwise
-
deleteDir
- Parameters:
dir
- File to delete. If it is not dir, deletes this File. Otherwise deletes dir recursively- Returns:
- true, if dir (or file) removed successfully
-