Class BackupUtil

java.lang.Object
com.sun.javatest.util.BackupUtil

public class BackupUtil extends Object
  • Constructor Details

    • BackupUtil

      public BackupUtil()
      Creates a new instance of BackupUtil
  • Method Details

    • backupFile

      public static int backupFile(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 backup
      maxBackups - Maximum number of allowed backups
      Returns:
      number of backup levels after finishing operation.
    • backupDir

      public static void backupDir(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(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 situated
      maxBackups - max allowed time to backup
    • backupContents

      public static void backupContents(File dir, int maxBackups)
      backups all files in the directory. No rename of directory. Not - recursive
    • checkForInteger

      public static boolean checkForInteger(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(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