Package com.sun.javatest.util
Class BackupUtil
- java.lang.Object
-
- com.sun.javatest.util.BackupUtil
-
public class BackupUtil extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description BackupUtil()
Creates a new instance of BackupUtil
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
backupAllSubdirs(java.io.File dir, int maxBackups)
Backups all found "layers" of subdirs.static void
backupContents(java.io.File dir, int maxBackups)
backups all files in the directory.static void
backupDir(java.io.File file, int maxBackups)
This method created to backup dirs.static int
backupFile(java.io.File file, int maxBackups)
Performs backup of file.static boolean
checkForInteger(java.lang.String s)
static boolean
deleteDir(java.io.File dir)
-
-
-
Method Detail
-
backupFile
public static int backupFile(java.io.File file, int maxBackups)
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
public static void backupDir(java.io.File file, int maxBackups)
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
public static void backupAllSubdirs(java.io.File dir, int maxBackups)
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
public static void backupContents(java.io.File dir, int maxBackups)
backups all files in the directory. No rename of directory. Not - recursive
-
checkForInteger
public static boolean checkForInteger(java.lang.String s)
- Parameters:
s
- Checks, if this String represents integer number- Returns:
- true, if if this String represents integer number, false otherwise
-
deleteDir
public static boolean deleteDir(java.io.File dir)
- 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
-
-