de.hunsicker.io
Class FileBackup

java.lang.Object
  |
  +--de.hunsicker.io.FileBackup

public class FileBackup
extends java.lang.Object

Handles backup generation for files.

Version:
$Revision: 1.3 $
Author:
Marco Hunsicker

Field Summary
static int NUMBERED
          Make numbered backups of every file by appending ~REVISION~ to the file.
static int SIMPLE
          Make simple backups of every file.
 
Method Summary
static java.io.File create(java.io.File file, java.io.File directory)
          Returns the new backup file for the given file.
static java.io.File create(java.io.File file, java.io.File directory, int backupLevel)
          Returns the name of the new backup file for the given file..
static java.io.File create(java.io.File file, java.io.File directory, int backupType, java.lang.String suffix, int backupLevel)
          Returns the new backup file for the given file.
static java.io.File create(java.lang.String content, java.lang.String filename, java.io.File directory, int backupLevel)
          Creates and returns the new backup file for the given content.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMBERED

public static final int NUMBERED
Make numbered backups of every file by appending ~REVISION~ to the file. The revision count gets increased with every new backup.

See Also:
Constant Field Values

SIMPLE

public static final int SIMPLE
Make simple backups of every file. Filenames are not numbered and just end in a suffix that signifies a backup file, i.e. no revisions are available as every backup file overwrites the last backup written.

See Also:
Constant Field Values
Method Detail

create

public static java.io.File create(java.io.File file,
                                  java.io.File directory)
                           throws java.io.IOException
Returns the new backup file for the given file. Uses a backup level of 5.

Parameters:
file - the file to back up.
directory - the directory to copy the backup to. If the directory doesn't exist, it will be created.
Returns:
the created backup file.
Throws:
java.io.IOException - if an I/O error occured.

create

public static java.io.File create(java.io.File file,
                                  java.io.File directory,
                                  int backupLevel)
                           throws java.io.IOException
Returns the name of the new backup file for the given file..

Parameters:
file - the file to back up.
directory - the directory to copy the backup to. If the directory doesn't exist, it will be created.
backupLevel - number of revisions to hold.
Returns:
the created backup file.
Throws:
java.io.IOException - if an I/O error occured.

create

public static java.io.File create(java.lang.String content,
                                  java.lang.String filename,
                                  java.io.File directory,
                                  int backupLevel)
                           throws java.io.IOException
Creates and returns the new backup file for the given content.

Parameters:
content - content to write to a backup file.
filename - the filename of the backup file.
directory - the directory to create the backup in. If the directory doesn't exist, it will be created.
backupLevel - number of revisions to hold.
Returns:
the created backup file.
Throws:
java.io.IOException - if an I/O error occured.

create

public static java.io.File create(java.io.File file,
                                  java.io.File directory,
                                  int backupType,
                                  java.lang.String suffix,
                                  int backupLevel)
                           throws java.io.IOException
Returns the new backup file for the given file.

Parameters:
file - the file to back up.
directory - the directory to copy the backup to. If the directory doesn't exist, it will be created.
backupType - the type of the backup. Either SIMPLE or NUMBERED.
suffix - the suffix to designate a backup file, ignored for the NUMBERED backup type.
backupLevel - number of revisions to hold, ignored for the SIMPLE backup type.
Returns:
the created backup file.
Throws:
java.io.IOException - if an I/O error occured.


Copyright © 1997-2005 Jalopy. All Rights Reserved.