com.sun.javatest.util
Class BackupUtil

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

public class BackupUtil
extends java.lang.Object


Constructor Summary
BackupUtil()
          Creates a new instance of BackupUtil
 
Method Summary
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackupUtil

public BackupUtil()
Creates a new instance of BackupUtil

Method Detail

backupFile

public static int backupFile(java.io.File file,
                             int maxBackups)
Performs backup of file. Searchs 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(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 parametr 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 situated
maxBackups - 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


Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.