org.jscience.io
Class ExtendedFile

java.lang.Object
  extended by java.io.File
      extended by org.jscience.io.ExtendedFile
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<java.io.File>
Direct Known Subclasses:
ServerLogFile

public class ExtendedFile
extends java.io.File

A specialized File class that provides some additional functionality. ExtendedFile adds no members to class File, only methods.

Since:
3/23/2002
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparatorChar, separator, separatorChar
 
Constructor Summary
ExtendedFile(java.io.File file)
          Creates a new ExtendedFile object.
ExtendedFile(java.io.File parent, java.lang.String child)
          Creates a new ExtendedFile object.
ExtendedFile(java.lang.String pathname)
          Creates a new ExtendedFile object.
ExtendedFile(java.lang.String parent, java.lang.String child)
          Creates a new ExtendedFile object.
ExtendedFile(java.net.URI uri)
          Creates a new ExtendedFile object.
 
Method Summary
 void append(java.io.File file)
          appends the content of the given file to this file
 void clear()
          deletes the content of the file
 boolean compareContent(java.io.File file)
          returns true only if both files have the exact same content
 boolean compareContent(long beginIndexThisFile, java.io.File otherFile, long beginIndexOtherFile, long maxBytes)
          returns true only if both files have the exact same content beginning at beginIndex and up to maxBytes number of bytes.
 ExtendedFile compress(boolean deleteOriginal)
          compresses the file using gzip to a file named by adding the type gz to the original name.
 void compressTo(java.io.File file)
          writes a gzip compressed file that can be uncompressed to its original form using uncompressTo(File).
 void copyTo(java.io.File destinationFile)
          copies this file to the given destination file.
 void copyTo(java.io.File destinationFile, byte[] searchPattern, byte[] replacePattern)
          copies this file to the given destination file while searchPattern is replaced with replacePattern
 int count(byte[] pattern)
          returns how many times the given byte pattern occurs within the file
 void decrypt(SynchronousKey key)
          the file must fit into memory
 void directoryCompare(java.io.File dir, java.io.PrintStream ps)
          compares this directory with the given one and prints results to the given stream
 void directoryCompare(java.io.File dir, java.io.PrintStream ps, Monitor monitor)
          DOCUMENT ME!
 void encrypt(SynchronousKey key)
          the file must fit into memory
 java.lang.String fileCompareText(java.io.File file)
          returns a text describing as to how this file compares to the given file
 java.lang.String fileCompareText(long beginIndexThisFile, java.io.File otherFile, long beginIndexOtherFile, long maxBytes)
          returns a text describing as to how this file compares to the given file
 byte[] getContentAsBytes()
          returns the entire file content as a byte array.
 java.lang.String getContentAsString()
          returns the entire file content as a String (using default encoding).
 java.lang.String getContentAsString(java.lang.String charsetName)
          returns the entire file content as a String (using default encoding).
 java.lang.String getFileExtension()
          returns the file type denoted by its file extension.
 ExtendedFile getFileRelativeTo(java.io.File dir)
          returns the file as a relative reference from the given directory.
static java.lang.String[] getFileTypes(java.io.File[] file)
          returns the different file extensions that occur in the given array
 boolean hasParent(java.io.File dir)
          returns true only if this ExtendedFile is in the given dir (or sub-dir)
 long indexOf(byte[] pattern)
          returns the index of the beginning of the given pattern within the file (beginning the search at beginIndex) or -1
 long indexOf(byte[] pattern, int beginIndex)
          returns the index of the beginning of the given pattern within the file (beginning the search at beginIndex) or -1
 int indexOf(java.lang.String pattern)
          returns the index within the content of this file of the first occurrence of the specified pattern; -1 is returned if pattern is not found.
 long length()
          in case of a directory, the combined size of all files within the tree is returned; otherwise the file size.
 ExtendedFile[] listFilesInTree()
          returns all files including those in subdirectories recursively
 ExtendedFile[] listFilesInTree(java.io.FileFilter filter)
          DOCUMENT ME!
 ExtendedFile[] listFilesInTree(java.io.FilenameFilter filter)
          DOCUMENT ME!
 java.io.File[] listSubDirs()
          assuming the current ExtendedFile is a directory, all sub-directories are returned.
 java.lang.Object loadObject()
          calls loadObject(false)
 java.lang.Object loadObject(boolean useDeserialization)
          loads a single object from the file into memory and returns it.
 java.util.Properties loadProperties()
          DOCUMENT ME!
 java.util.Enumeration objectEnumerator()
          returns an Enumeration over the objects contained in this binary file with serialized objects written with an ObjectOutputStream
 java.util.Enumeration objectEnumerator(boolean useDeserialization)
          returns an Enumeration over the objects contained in this binary file with serialized objects written with an ObjectOutputStream.
 java.util.Enumeration objectEnumerator(boolean useDeserialization, Logger exceptionLogger)
          convenience method
 boolean removeTree(boolean includingThisRoot)
          If the ExtendedFile at hand is a directory, this method attempts to delete the entire subtree; therefore use it with caution!
 void replace(byte[] searchPattern, byte[] replacePattern)
          searches for the first pattern and replaces all occurrences with the second pattern.
 void replace(java.lang.String searchPattern, java.lang.String replacePattern)
          searches for the first pattern and replaces all occurrences with the second pattern (no regular expressions used).
 void storeProperties(java.util.Properties props, java.lang.String comment)
          DOCUMENT ME!
 ExtendedFile[] synchronizeDir(java.io.File destinationDir)
          Assuming the current ExtendedFile is a directory, this method synchronizes it with the destination directory by writing all files into the destination directory that exist in the origin directory.
 ExtendedFile[] synchronizeDir(java.io.File destinationDir, java.io.FileFilter filter)
          synchronizes only those files that are accepted by the filter
 ExtendedFile[] synchronizeDir(java.io.File destinationDir, java.io.FileFilter filter, Logger logger, Monitor monitor)
          DOCUMENT ME!
 ExtendedFile[] synchronizeDir(java.io.File destinationDir, Logger logger)
          This method allows for intermediate feedback through the logger; otherwise it's the same as the other synchronizeDir() method.
 ExtendedFile[] synchronizeDir(java.io.File destinationDir, Logger logger, Monitor monitor)
          This method allows for intermediate feedback and interactive stopping; otherwise it's the same as the other synchronizeDir() method.
 boolean touch()
          returns setLastModified(System.currentTimeMillis()) after possibly creating the file if it didn't exist before.
 void uncompressTo(java.io.File file)
          restores a gzip compressed file written with compressTo(File).
 void unzipTo(java.io.File directory)
          calls unzipTo(directory, true)
 void unzipTo(java.io.File directory, boolean overwriteExistingFiles)
          DOCUMENT ME!
 void unzipTo(java.io.File directory, boolean overwriteExistingFiles, Monitor monitor)
          DOCUMENT ME!
 void unzipTo(java.io.File directory, java.io.FileFilter filter, Monitor monitor)
          allows to react individually per file on whether to unzip it or nor
 void writeBytes(byte[] bytes, boolean append)
          writes the given bytes directly to the file and flushes; if append is false, all previous content will be overwritten.
 void writeln()
          appends a platform specific linebreak into a text file
 void writeObject(java.lang.Object obj, boolean append)
          serializes the given object, writes it to the file and flushes.
 boolean writeStackTrace(java.lang.Thread t, java.lang.Throwable e, boolean append)
          prints the stack trace of the given Throwable to a PrintWriter.
 void writeStackTrace(java.lang.Throwable t, boolean append)
          prints the stack trace of the given Throwable
 void writeText(java.lang.String text, boolean append)
          writes the given text to the file and flushes; if append is false, all previous content will be overwritten.
 void zipTo(java.io.File file)
          zips either this file this directory three to the given file
 void zipTo(java.io.File file, java.io.FileFilter filter, java.lang.String comment, Monitor monitor)
          only the file parameter must not be null
 void zipTo(java.io.File file, java.lang.String comment, Monitor monitor)
          DOCUMENT ME!
 
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExtendedFile

public ExtendedFile(java.io.File file)
Creates a new ExtendedFile object.

Parameters:
file - DOCUMENT ME!

ExtendedFile

public ExtendedFile(java.lang.String pathname)
Creates a new ExtendedFile object.

Parameters:
pathname - DOCUMENT ME!

ExtendedFile

public ExtendedFile(java.lang.String parent,
                    java.lang.String child)
Creates a new ExtendedFile object.

Parameters:
parent - DOCUMENT ME!
child - DOCUMENT ME!

ExtendedFile

public ExtendedFile(java.io.File parent,
                    java.lang.String child)
Creates a new ExtendedFile object.

Parameters:
parent - DOCUMENT ME!
child - DOCUMENT ME!

ExtendedFile

public ExtendedFile(java.net.URI uri)
Creates a new ExtendedFile object.

Parameters:
uri - DOCUMENT ME!
Method Detail

touch

public boolean touch()
              throws java.io.IOException
returns setLastModified(System.currentTimeMillis()) after possibly creating the file if it didn't exist before.

Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

clear

public void clear()
           throws java.io.IOException
deletes the content of the file

Throws:
java.io.IOException - DOCUMENT ME!

length

public long length()
in case of a directory, the combined size of all files within the tree is returned; otherwise the file size.

Overrides:
length in class java.io.File
Returns:
DOCUMENT ME!

getFileExtension

public java.lang.String getFileExtension()
returns the file type denoted by its file extension. The extension is the String of those characters that follow the last 'dot' (".") in the file name in lowercase. If no extension is present, null is returned.

Returns:
DOCUMENT ME!

hasParent

public boolean hasParent(java.io.File dir)
returns true only if this ExtendedFile is in the given dir (or sub-dir)

Parameters:
dir - DOCUMENT ME!
Returns:
DOCUMENT ME!

getFileRelativeTo

public ExtendedFile getFileRelativeTo(java.io.File dir)
returns the file as a relative reference from the given directory. The given directory should be a parent of the file at hand; if not, the absolute file path is returned.

Parameters:
dir - DOCUMENT ME!
Returns:
DOCUMENT ME!

listSubDirs

public java.io.File[] listSubDirs()
assuming the current ExtendedFile is a directory, all sub-directories are returned.

Returns:
DOCUMENT ME!

listFilesInTree

public ExtendedFile[] listFilesInTree()
returns all files including those in subdirectories recursively

Returns:
DOCUMENT ME!

listFilesInTree

public ExtendedFile[] listFilesInTree(java.io.FileFilter filter)
DOCUMENT ME!

Parameters:
filter - DOCUMENT ME!
Returns:
DOCUMENT ME!

listFilesInTree

public ExtendedFile[] listFilesInTree(java.io.FilenameFilter filter)
DOCUMENT ME!

Parameters:
filter - DOCUMENT ME!
Returns:
DOCUMENT ME!

copyTo

public void copyTo(java.io.File destinationFile)
            throws java.io.IOException
copies this file to the given destination file. The last modified time of the copied file will be set equal to the original file. The read-only attribute is NOT applied to the copied file even if the original file was read-only.

Parameters:
destinationFile - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

copyTo

public void copyTo(java.io.File destinationFile,
                   byte[] searchPattern,
                   byte[] replacePattern)
            throws java.io.IOException
copies this file to the given destination file while searchPattern is replaced with replacePattern

Parameters:
destinationFile - DOCUMENT ME!
searchPattern - DOCUMENT ME!
replacePattern - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

compareContent

public boolean compareContent(java.io.File file)
                       throws java.io.IOException
returns true only if both files have the exact same content

Parameters:
file - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

compareContent

public boolean compareContent(long beginIndexThisFile,
                              java.io.File otherFile,
                              long beginIndexOtherFile,
                              long maxBytes)
                       throws java.io.IOException
returns true only if both files have the exact same content beginning at beginIndex and up to maxBytes number of bytes.

Parameters:
beginIndexThisFile - DOCUMENT ME!
otherFile - DOCUMENT ME!
beginIndexOtherFile - DOCUMENT ME!
maxBytes - if 0, the entire content is compared to EOF
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

fileCompareText

public java.lang.String fileCompareText(java.io.File file)
                                 throws java.io.IOException
returns a text describing as to how this file compares to the given file

Parameters:
file - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

fileCompareText

public java.lang.String fileCompareText(long beginIndexThisFile,
                                        java.io.File otherFile,
                                        long beginIndexOtherFile,
                                        long maxBytes)
                                 throws java.io.IOException
returns a text describing as to how this file compares to the given file

Parameters:
beginIndexThisFile - DOCUMENT ME!
otherFile - DOCUMENT ME!
beginIndexOtherFile - DOCUMENT ME!
maxBytes - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

directoryCompare

public void directoryCompare(java.io.File dir,
                             java.io.PrintStream ps)
                      throws java.io.IOException
compares this directory with the given one and prints results to the given stream

Parameters:
dir - DOCUMENT ME!
ps - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

directoryCompare

public void directoryCompare(java.io.File dir,
                             java.io.PrintStream ps,
                             Monitor monitor)
                      throws java.io.IOException
DOCUMENT ME!

Parameters:
dir - DOCUMENT ME!
ps - DOCUMENT ME!
monitor - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

synchronizeDir

public ExtendedFile[] synchronizeDir(java.io.File destinationDir)
                              throws java.io.IOException
Assuming the current ExtendedFile is a directory, this method synchronizes it with the destination directory by writing all files into the destination directory that exist in the origin directory.

The procedure follows the follwing rules:

Note that file attributes are ignored, i.e. if a file is copied, the default attributes are kept and may be different from those of the originating file. If a directory is to be removed in the destination dir, the method makes a best effort to do so.

Parameters:
destinationDir - DOCUMENT ME!
Returns:
array of files that could not be copied or deleted; if no errors occurred, this array would be empty
Throws:
java.io.IOException - if either the current ExtendedFile or the given destination are not directories

synchronizeDir

public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
                                     java.io.FileFilter filter)
                              throws java.io.IOException
synchronizes only those files that are accepted by the filter

Parameters:
destinationDir - DOCUMENT ME!
filter - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

synchronizeDir

public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
                                     Logger logger)
                              throws java.io.IOException
This method allows for intermediate feedback through the logger; otherwise it's the same as the other synchronizeDir() method.

This method allows e.g. GUIs to display status messages by implementing a special LogWriter.
The given logger may be null, otherwise its usage is as follows:

Parameters:
destinationDir - DOCUMENT ME!
logger - DOCUMENT ME!
Returns:
array of files that could not be copied or deleted; if no errors occurred, this array would be empty
Throws:
java.io.IOException - DOCUMENT ME!
See Also:
synchronizeDir(File), Backup

synchronizeDir

public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
                                     Logger logger,
                                     Monitor monitor)
                              throws java.io.IOException
This method allows for intermediate feedback and interactive stopping; otherwise it's the same as the other synchronizeDir() method.

This method allows monitoring threads to abort the synchronization by disabling the given monitor during processing. The monitor/logger may be null; monitor checks occur for each directory and after each copy operation - right after the logger was called to log the operation.

Parameters:
destinationDir - DOCUMENT ME!
logger - DOCUMENT ME!
monitor - DOCUMENT ME!
Returns:
array of files that could not be copied or deleted; if no errors occurred, this array would be empty
Throws:
java.io.IOException - DOCUMENT ME!
See Also:
synchronizeDir(File,Logger), Backup

synchronizeDir

public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
                                     java.io.FileFilter filter,
                                     Logger logger,
                                     Monitor monitor)
                              throws java.io.IOException
DOCUMENT ME!

Parameters:
destinationDir - DOCUMENT ME!
filter - DOCUMENT ME!
logger - DOCUMENT ME!
monitor - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

removeTree

public boolean removeTree(boolean includingThisRoot)
If the ExtendedFile at hand is a directory, this method attempts to delete the entire subtree; therefore use it with caution!

If the ExtendedFile is not a directory, false is returned immediately (nothing gets deleted). If it is a directory but it is not empty, it will attempt to first delete all content recursively and then again the top directory. The method may return false as soon as any subdirectory could not be removed, i.e. not necessarily everything that could be deleted within the tree may be deleted if the method returns false in the case of a directory; still: all files handled before will be deleted.

Parameters:
includingThisRoot - if true, this directory is deleted along with the sub-tree
Returns:
true only if ExtendedFile is a directory and the entire subtree was successfully removed

indexOf

public int indexOf(java.lang.String pattern)
            throws java.io.IOException,
                   java.lang.OutOfMemoryError
returns the index within the content of this file of the first occurrence of the specified pattern; -1 is returned if pattern is not found. This method is to be used with smaller/medium sized text files; the entire file must fit into memory.

Parameters:
pattern - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memory

indexOf

public long indexOf(byte[] pattern)
             throws java.io.IOException
returns the index of the beginning of the given pattern within the file (beginning the search at beginIndex) or -1

Parameters:
pattern - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

indexOf

public long indexOf(byte[] pattern,
                    int beginIndex)
             throws java.io.IOException
returns the index of the beginning of the given pattern within the file (beginning the search at beginIndex) or -1

Parameters:
pattern - DOCUMENT ME!
beginIndex - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

count

public int count(byte[] pattern)
          throws java.io.IOException
returns how many times the given byte pattern occurs within the file

Parameters:
pattern - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

replace

public void replace(java.lang.String searchPattern,
                    java.lang.String replacePattern)
             throws java.io.IOException,
                    java.lang.OutOfMemoryError
searches for the first pattern and replaces all occurrences with the second pattern (no regular expressions used). This method is to be used with smaller/medium sized text files; the entire file must fit into memory (twice, actually).

Parameters:
searchPattern - DOCUMENT ME!
replacePattern - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memory

replace

public void replace(byte[] searchPattern,
                    byte[] replacePattern)
             throws java.io.IOException
searches for the first pattern and replaces all occurrences with the second pattern. Uses a temp file for the replacement; data is then copied back to the original file

Parameters:
searchPattern - DOCUMENT ME!
replacePattern - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

getContentAsString

public java.lang.String getContentAsString()
                                    throws java.io.IOException,
                                           java.lang.OutOfMemoryError
returns the entire file content as a String (using default encoding). This method is better to be used with smaller/medium sized text files; the entire file must fit into memory.

Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memory
See Also:
getContentAsBytes()

getContentAsString

public java.lang.String getContentAsString(java.lang.String charsetName)
                                    throws java.io.IOException,
                                           java.lang.OutOfMemoryError
returns the entire file content as a String (using default encoding). This method is better to be used with smaller/medium sized text files; the entire file must fit into memory.

Parameters:
charsetName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memory
See Also:
getContentAsBytes()

getContentAsBytes

public byte[] getContentAsBytes()
                         throws java.io.IOException,
                                java.lang.OutOfMemoryError
returns the entire file content as a byte array. This method is better to be used with smaller/medium sized binary files; the entire file must fit into memory.

Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memory
See Also:
getContentAsString()

append

public void append(java.io.File file)
            throws java.io.IOException
appends the content of the given file to this file

Parameters:
file - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

writeText

public void writeText(java.lang.String text,
                      boolean append)
               throws java.io.IOException
writes the given text to the file and flushes; if append is false, all previous content will be overwritten. Suitable for text files only

Throws:
java.io.IOException
See Also:
writeObject(Object,boolean)

writeln

public void writeln()
             throws java.io.IOException
appends a platform specific linebreak into a text file

Throws:
java.io.IOException - DOCUMENT ME!

writeBytes

public void writeBytes(byte[] bytes,
                       boolean append)
                throws java.io.IOException
writes the given bytes directly to the file and flushes; if append is false, all previous content will be overwritten. Suitable for binary files.

Throws:
java.io.IOException
See Also:
writeObject(Object,boolean)

writeObject

public void writeObject(java.lang.Object obj,
                        boolean append)
                 throws java.io.IOException
serializes the given object, writes it to the file and flushes. Use with binary files only. Note: appending different objects to an existing file may result into ClassCastException in ObjectInputStream when reading back from the file; one solution is to simply write byte arrays as objects that contain the already serialized object.

Parameters:
obj - DOCUMENT ME!
append - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
See Also:
writeText(String,boolean), writeBytes(byte[],boolean), IOUtils.serialize(java.lang.Object)

writeStackTrace

public void writeStackTrace(java.lang.Throwable t,
                            boolean append)
                     throws java.io.IOException
prints the stack trace of the given Throwable

Parameters:
t - DOCUMENT ME!
append - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

writeStackTrace

public boolean writeStackTrace(java.lang.Thread t,
                               java.lang.Throwable e,
                               boolean append)
                        throws java.io.FileNotFoundException
prints the stack trace of the given Throwable to a PrintWriter.

Parameters:
t - DOCUMENT ME!
e - DOCUMENT ME!
append - DOCUMENT ME!
Returns:
true only if the stack was successfully written.
Throws:
java.io.FileNotFoundException - DOCUMENT ME!

compressTo

public void compressTo(java.io.File file)
                throws java.io.IOException
writes a gzip compressed file that can be uncompressed to its original form using uncompressTo(File).

Throws:
java.io.IOException
See Also:
uncompressTo(File)

uncompressTo

public void uncompressTo(java.io.File file)
                  throws java.io.IOException
restores a gzip compressed file written with compressTo(File).

Throws:
java.io.IOException
See Also:
compressTo(File)

compress

public ExtendedFile compress(boolean deleteOriginal)
                      throws java.io.IOException
compresses the file using gzip to a file named by adding the type gz to the original name.

Parameters:
deleteOriginal - if true, the uncompressed original file will be deleted
Returns:
the compressed file
Throws:
java.io.IOException - DOCUMENT ME!

loadObject

public java.lang.Object loadObject()
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
calls loadObject(false)

Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.ClassNotFoundException - DOCUMENT ME!

loadObject

public java.lang.Object loadObject(boolean useDeserialization)
                            throws java.io.IOException,
                                   java.lang.ClassNotFoundException
loads a single object from the file into memory and returns it.

Parameters:
useDeserialization - if true, this method attepts deserialization on byte arrays
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.ClassNotFoundException - DOCUMENT ME!

loadProperties

public java.util.Properties loadProperties()
                                    throws java.io.IOException
DOCUMENT ME!

Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

storeProperties

public void storeProperties(java.util.Properties props,
                            java.lang.String comment)
                     throws java.io.IOException
DOCUMENT ME!

Parameters:
props - DOCUMENT ME!
comment - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

encrypt

public void encrypt(SynchronousKey key)
             throws java.io.IOException,
                    java.lang.OutOfMemoryError
the file must fit into memory

Parameters:
key - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - DOCUMENT ME!

decrypt

public void decrypt(SynchronousKey key)
             throws java.io.IOException,
                    java.lang.OutOfMemoryError
the file must fit into memory

Parameters:
key - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - DOCUMENT ME!

objectEnumerator

public java.util.Enumeration objectEnumerator()
                                       throws java.io.FileNotFoundException
returns an Enumeration over the objects contained in this binary file with serialized objects written with an ObjectOutputStream

Returns:
DOCUMENT ME!
Throws:
java.io.FileNotFoundException - DOCUMENT ME!
See Also:
writeObject(Object,boolean), ObjectEnumerator

objectEnumerator

public java.util.Enumeration objectEnumerator(boolean useDeserialization)
                                       throws java.io.FileNotFoundException
returns an Enumeration over the objects contained in this binary file with serialized objects written with an ObjectOutputStream.

Parameters:
useDeserialization - specifies whether - in case the object to be returned is a byte[] - automatic deserialization should be used. If the deserialization fails, a byte[] is always returned if present.
Returns:
DOCUMENT ME!
Throws:
java.io.FileNotFoundException - DOCUMENT ME!
See Also:
writeObject(Object,boolean), IOUtils.deserialize(byte[]), ObjectEnumerator

objectEnumerator

public java.util.Enumeration objectEnumerator(boolean useDeserialization,
                                              Logger exceptionLogger)
                                       throws java.io.FileNotFoundException
convenience method

Throws:
java.io.FileNotFoundException
See Also:
ObjectEnumerator

zipTo

public void zipTo(java.io.File file)
           throws java.io.IOException
zips either this file this directory three to the given file

Parameters:
file - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

zipTo

public void zipTo(java.io.File file,
                  java.lang.String comment,
                  Monitor monitor)
           throws java.io.IOException
DOCUMENT ME!

Parameters:
file - DOCUMENT ME!
comment - DOCUMENT ME!
monitor - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

zipTo

public void zipTo(java.io.File file,
                  java.io.FileFilter filter,
                  java.lang.String comment,
                  Monitor monitor)
           throws java.io.IOException
only the file parameter must not be null

Parameters:
file - DOCUMENT ME!
filter - DOCUMENT ME!
comment - DOCUMENT ME!
monitor - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

unzipTo

public void unzipTo(java.io.File directory)
             throws java.io.IOException
calls unzipTo(directory, true)

Parameters:
directory - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

unzipTo

public void unzipTo(java.io.File directory,
                    boolean overwriteExistingFiles)
             throws java.io.IOException
DOCUMENT ME!

Parameters:
directory - DOCUMENT ME!
overwriteExistingFiles - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

unzipTo

public void unzipTo(java.io.File directory,
                    boolean overwriteExistingFiles,
                    Monitor monitor)
             throws java.io.IOException
DOCUMENT ME!

Parameters:
directory - DOCUMENT ME!
overwriteExistingFiles - DOCUMENT ME!
monitor - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

unzipTo

public void unzipTo(java.io.File directory,
                    java.io.FileFilter filter,
                    Monitor monitor)
             throws java.io.IOException
allows to react individually per file on whether to unzip it or nor

Parameters:
directory - DOCUMENT ME!
filter - DOCUMENT ME!
monitor - DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

getFileTypes

public static java.lang.String[] getFileTypes(java.io.File[] file)
returns the different file extensions that occur in the given array

Parameters:
file - DOCUMENT ME!
Returns:
DOCUMENT ME!