|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.File
org.jscience.io.ExtendedFile
public class ExtendedFile
A specialized File class that provides some additional functionality. ExtendedFile adds no members to class File, only methods.
| 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 |
|---|
public ExtendedFile(java.io.File file)
file - DOCUMENT ME!public ExtendedFile(java.lang.String pathname)
pathname - DOCUMENT ME!
public ExtendedFile(java.lang.String parent,
java.lang.String child)
parent - DOCUMENT ME!child - DOCUMENT ME!
public ExtendedFile(java.io.File parent,
java.lang.String child)
parent - DOCUMENT ME!child - DOCUMENT ME!public ExtendedFile(java.net.URI uri)
uri - DOCUMENT ME!| Method Detail |
|---|
public boolean touch()
throws java.io.IOException
setLastModified(System.currentTimeMillis())
after possibly creating the file if it didn't exist before.
java.io.IOException - DOCUMENT ME!
public void clear()
throws java.io.IOException
java.io.IOException - DOCUMENT ME!public long length()
length in class java.io.Filepublic java.lang.String getFileExtension()
public boolean hasParent(java.io.File dir)
dir - DOCUMENT ME!
public ExtendedFile getFileRelativeTo(java.io.File dir)
dir - DOCUMENT ME!
public java.io.File[] listSubDirs()
public ExtendedFile[] listFilesInTree()
public ExtendedFile[] listFilesInTree(java.io.FileFilter filter)
filter - DOCUMENT ME!
public ExtendedFile[] listFilesInTree(java.io.FilenameFilter filter)
filter - DOCUMENT ME!
public void copyTo(java.io.File destinationFile)
throws java.io.IOException
destinationFile - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void copyTo(java.io.File destinationFile,
byte[] searchPattern,
byte[] replacePattern)
throws java.io.IOException
destinationFile - DOCUMENT ME!searchPattern - DOCUMENT ME!replacePattern - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public boolean compareContent(java.io.File file)
throws java.io.IOException
file - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public boolean compareContent(long beginIndexThisFile,
java.io.File otherFile,
long beginIndexOtherFile,
long maxBytes)
throws java.io.IOException
beginIndexThisFile - DOCUMENT ME!otherFile - DOCUMENT ME!beginIndexOtherFile - DOCUMENT ME!maxBytes - if 0, the entire content is compared to EOF
java.io.IOException - DOCUMENT ME!
public java.lang.String fileCompareText(java.io.File file)
throws java.io.IOException
file - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public java.lang.String fileCompareText(long beginIndexThisFile,
java.io.File otherFile,
long beginIndexOtherFile,
long maxBytes)
throws java.io.IOException
beginIndexThisFile - DOCUMENT ME!otherFile - DOCUMENT ME!beginIndexOtherFile - DOCUMENT ME!maxBytes - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void directoryCompare(java.io.File dir,
java.io.PrintStream ps)
throws java.io.IOException
dir - DOCUMENT ME!ps - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void directoryCompare(java.io.File dir,
java.io.PrintStream ps,
Monitor monitor)
throws java.io.IOException
dir - DOCUMENT ME!ps - DOCUMENT ME!monitor - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!
public ExtendedFile[] synchronizeDir(java.io.File destinationDir)
throws java.io.IOException
The procedure follows the follwing rules:
destinationDir - DOCUMENT ME!
java.io.IOException - if either the current ExtendedFile or the given
destination are not directories
public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
java.io.FileFilter filter)
throws java.io.IOException
destinationDir - DOCUMENT ME!filter - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
Logger logger)
throws java.io.IOException
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:
destinationDir - DOCUMENT ME!logger - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!synchronizeDir(File),
Backup
public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
Logger logger,
Monitor monitor)
throws java.io.IOException
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.
destinationDir - DOCUMENT ME!logger - DOCUMENT ME!monitor - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!synchronizeDir(File,Logger),
Backup
public ExtendedFile[] synchronizeDir(java.io.File destinationDir,
java.io.FileFilter filter,
Logger logger,
Monitor monitor)
throws java.io.IOException
destinationDir - DOCUMENT ME!filter - DOCUMENT ME!logger - DOCUMENT ME!monitor - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!public boolean removeTree(boolean includingThisRoot)
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.
includingThisRoot - if true, this directory is deleted along with
the sub-tree
public int indexOf(java.lang.String pattern)
throws java.io.IOException,
java.lang.OutOfMemoryError
pattern - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memory
public long indexOf(byte[] pattern)
throws java.io.IOException
pattern - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public long indexOf(byte[] pattern,
int beginIndex)
throws java.io.IOException
pattern - DOCUMENT ME!beginIndex - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public int count(byte[] pattern)
throws java.io.IOException
pattern - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void replace(java.lang.String searchPattern,
java.lang.String replacePattern)
throws java.io.IOException,
java.lang.OutOfMemoryError
searchPattern - DOCUMENT ME!replacePattern - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memory
public void replace(byte[] searchPattern,
byte[] replacePattern)
throws java.io.IOException
searchPattern - DOCUMENT ME!replacePattern - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public java.lang.String getContentAsString()
throws java.io.IOException,
java.lang.OutOfMemoryError
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memorygetContentAsBytes()
public java.lang.String getContentAsString(java.lang.String charsetName)
throws java.io.IOException,
java.lang.OutOfMemoryError
charsetName - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memorygetContentAsBytes()
public byte[] getContentAsBytes()
throws java.io.IOException,
java.lang.OutOfMemoryError
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - if the file doesn't fit into memorygetContentAsString()
public void append(java.io.File file)
throws java.io.IOException
file - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void writeText(java.lang.String text,
boolean append)
throws java.io.IOException
java.io.IOExceptionwriteObject(Object,boolean)
public void writeln()
throws java.io.IOException
java.io.IOException - DOCUMENT ME!
public void writeBytes(byte[] bytes,
boolean append)
throws java.io.IOException
java.io.IOExceptionwriteObject(Object,boolean)
public void writeObject(java.lang.Object obj,
boolean append)
throws java.io.IOException
obj - DOCUMENT ME!append - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!writeText(String,boolean),
writeBytes(byte[],boolean),
IOUtils.serialize(java.lang.Object)
public void writeStackTrace(java.lang.Throwable t,
boolean append)
throws java.io.IOException
t - DOCUMENT ME!append - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public boolean writeStackTrace(java.lang.Thread t,
java.lang.Throwable e,
boolean append)
throws java.io.FileNotFoundException
t - DOCUMENT ME!e - DOCUMENT ME!append - DOCUMENT ME!
java.io.FileNotFoundException - DOCUMENT ME!
public void compressTo(java.io.File file)
throws java.io.IOException
uncompressTo(File).
java.io.IOExceptionuncompressTo(File)
public void uncompressTo(java.io.File file)
throws java.io.IOException
compressTo(File).
java.io.IOExceptioncompressTo(File)
public ExtendedFile compress(boolean deleteOriginal)
throws java.io.IOException
deleteOriginal - if true, the uncompressed original file will be
deleted
java.io.IOException - DOCUMENT ME!
public java.lang.Object loadObject()
throws java.io.IOException,
java.lang.ClassNotFoundException
loadObject(false)
java.io.IOException - DOCUMENT ME!
java.lang.ClassNotFoundException - DOCUMENT ME!
public java.lang.Object loadObject(boolean useDeserialization)
throws java.io.IOException,
java.lang.ClassNotFoundException
useDeserialization - if true, this method attepts deserialization
on byte arrays
java.io.IOException - DOCUMENT ME!
java.lang.ClassNotFoundException - DOCUMENT ME!
public java.util.Properties loadProperties()
throws java.io.IOException
java.io.IOException - DOCUMENT ME!
public void storeProperties(java.util.Properties props,
java.lang.String comment)
throws java.io.IOException
props - DOCUMENT ME!comment - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void encrypt(SynchronousKey key)
throws java.io.IOException,
java.lang.OutOfMemoryError
key - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - DOCUMENT ME!
public void decrypt(SynchronousKey key)
throws java.io.IOException,
java.lang.OutOfMemoryError
key - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.OutOfMemoryError - DOCUMENT ME!
public java.util.Enumeration objectEnumerator()
throws java.io.FileNotFoundException
java.io.FileNotFoundException - DOCUMENT ME!writeObject(Object,boolean),
ObjectEnumerator
public java.util.Enumeration objectEnumerator(boolean useDeserialization)
throws java.io.FileNotFoundException
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.
java.io.FileNotFoundException - DOCUMENT ME!writeObject(Object,boolean),
IOUtils.deserialize(byte[]),
ObjectEnumerator
public java.util.Enumeration objectEnumerator(boolean useDeserialization,
Logger exceptionLogger)
throws java.io.FileNotFoundException
java.io.FileNotFoundExceptionObjectEnumerator
public void zipTo(java.io.File file)
throws java.io.IOException
file - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void zipTo(java.io.File file,
java.lang.String comment,
Monitor monitor)
throws java.io.IOException
file - DOCUMENT ME!comment - DOCUMENT ME!monitor - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void zipTo(java.io.File file,
java.io.FileFilter filter,
java.lang.String comment,
Monitor monitor)
throws java.io.IOException
file - DOCUMENT ME!filter - DOCUMENT ME!comment - DOCUMENT ME!monitor - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!
public void unzipTo(java.io.File directory)
throws java.io.IOException
unzipTo(directory, true)
directory - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void unzipTo(java.io.File directory,
boolean overwriteExistingFiles)
throws java.io.IOException
directory - DOCUMENT ME!overwriteExistingFiles - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void unzipTo(java.io.File directory,
boolean overwriteExistingFiles,
Monitor monitor)
throws java.io.IOException
directory - DOCUMENT ME!overwriteExistingFiles - DOCUMENT ME!monitor - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
public void unzipTo(java.io.File directory,
java.io.FileFilter filter,
Monitor monitor)
throws java.io.IOException
directory - DOCUMENT ME!filter - DOCUMENT ME!monitor - DOCUMENT ME!
java.io.IOException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!public static java.lang.String[] getFileTypes(java.io.File[] file)
file - DOCUMENT ME!
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||