core
Class CopyFile

java.lang.Object
  extended by core.CopyFile

public class CopyFile
extends java.lang.Object

This class provides a simple way to copy a file that exists.


Field Summary
static java.lang.String FILE_SEPERATOR
          The character used to seperate files and folders.
 
Constructor Summary
CopyFile()
          Constructs a new CopyFile object without a file to copy.
CopyFile(java.io.File file)
          Constructs a new CopyFile object with a known file to copy.
 
Method Summary
 java.io.File copyFile(boolean showProgress)
          Creates a new copy of the original file without overwriting the file.
 void createZIPFileBackup(java.util.ArrayList<java.io.File> filesToZip)
          Creates a zip to the Data folder containing the given files with a name including the current time in milliseconds.
 java.io.File getOriginalFile()
          Returns the original file to copy
static void main(java.lang.String[] args)
           
 void setOriginalFile(java.io.File originalFile)
          Sets the file to copied in the CopyFile object
 java.io.File write(java.io.File outputFile, boolean showProgress)
          Copies the original file to a new file, if the file exists in the directory it will be given a name to prevent overwriting it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_SEPERATOR

public static final java.lang.String FILE_SEPERATOR
The character used to seperate files and folders. System dependent.

Constructor Detail

CopyFile

public CopyFile(java.io.File file)
Constructs a new CopyFile object with a known file to copy.

Parameters:
file - The file that is to be copied elsewhere.

CopyFile

public CopyFile()
Constructs a new CopyFile object without a file to copy. A file must be set before other methods can be called.

Method Detail

getOriginalFile

public java.io.File getOriginalFile()
Returns the original file to copy

Returns:
the original file to copy

setOriginalFile

public void setOriginalFile(java.io.File originalFile)
Sets the file to copied in the CopyFile object

Parameters:
originalFile - the file to copy

copyFile

public java.io.File copyFile(boolean showProgress)
Creates a new copy of the original file without overwriting the file.

Parameters:
showProgress - If true, a ProgressMonitorDialog box will appear showing the copy progress.
Returns:
The copied file

write

public java.io.File write(java.io.File outputFile,
                          boolean showProgress)
Copies the original file to a new file, if the file exists in the directory it will be given a name to prevent overwriting it. If the file does not exist in the destingation directory it will be given the same name as the original file.

Parameters:
outputFile - the file to output to. If the file exists in that directory it will be given a name that is unique.
showProgress - If true, a ProgressMonitorDialog box will appear showing the copy progress.
Returns:
The copied file. Null if there was a problem writing the file.

createZIPFileBackup

public void createZIPFileBackup(java.util.ArrayList<java.io.File> filesToZip)
Creates a zip to the Data folder containing the given files with a name including the current time in milliseconds.

Parameters:
filesToZip - The array list of files to include in a backup zip file in the user directory.

main

public static void main(java.lang.String[] args)