|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.File
de.schlichtherle.io.File
public class File
A drop-in replacement for its subclass which provides transparent read/write access to archive files and their entries as if they were (virtual) directories and files.
Warning:The classes in this package access and manipulate archive files as external resources and may cache some of their state in memory and temporary files. Third parties must not concurrently access these archive files unless some precautions have been taken! For more information please refer to the section "Managing Archive File State" in the package summary.
This class provides a bunch of convenient copy methods which work much faster and more reliable than the usual read-write-in-a-loop approach for individual files and its recursive companion for directory trees. These copy methods fall into the following categories:
IOException
on failure.
The exception hierarchy is fine grained enough to let a client
application differentiate between access restrictions, input exceptions
and output exceptions.
The method names have been modelled after the Unix "cp -p"
utility.
None of these methods does recursive copying, however.
java.nio
.
If data is copied from an archive file to another archive file of the same type, some of the copy methods use a feature called Direct Data Copying (DDC) to achieve even better performance: DDC copies the raw data from the source archive entry to the destination archive entry without the need to temporarily reproduce, copy and process the original data again.
The benefits of this feature are archive driver specific: In case of ZIP compatible files with compressed entries, it avoids the need to decompress the data from the source entry just to compress it again for the destination entry. In case of TAR compatible files, it avoids the need to create an additional temporary file, but shows no impact otherwise - TAR doesn't support compression.
Whenever an archive file suffix is recognized in a path, TrueZIP treats the corresponding file or directory as a prospective archive file. The word "prospective" suggests that just because a file is named archive.zip it isn't necessarily a valid ZIP file. In fact, it could be anything, even a regular directory!
Such an invalid archive file is called a false positive, which means a file, special file (a Unix concept) or directory which's path has a configured archive file suffix, but is actually something else. TrueZIP correctly identifies all kinds of false positives and treats them according to what they really are: Regular files, special files or directories.
The following table shows how certain methods in this class behave, depending upon a file's path and its true state in the file system:
Path | True State | isArchive() 1 |
isDirectory() |
isFile() |
exists() |
length() 2 |
---|---|---|---|---|---|---|
archive.zip3 | Valid ZIP file | true |
true |
false |
true |
0 |
archive.zip | False positive: Regular directory | true |
true |
false |
true |
? |
archive.zip | False positive: Regular file | true |
false |
true |
true |
? |
archive.zip | False positive: Regular special file | true |
false |
false |
true |
? |
archive.zip | File or directory does not exist | true |
false |
false |
false |
0 |
archive.tzp4 | Valid RAES encrypted ZIP file with valid key (e.g. password) | true |
true |
false |
true |
0 |
archive.tzp | Valid RAES encrypted ZIP file with unknown key5 | true |
false |
false |
true |
? |
archive.tzp | False positive: Regular directory | true |
true |
false |
true |
? |
archive.tzp | False positive: Regular file | true |
false |
true |
true |
? |
archive.tzp | False positive: Regular special file | true |
false |
false |
true |
? |
archive.tzp | File or directory does not exist | true |
false |
false |
false |
0 |
other | Regular directory | false |
true |
false |
true |
? |
other | Regular file | false |
false |
true |
true |
? |
other | Regular special file | false |
false |
false |
true |
? |
other | File or directory does not exist | false |
false |
false |
false |
0 |
isArchive()
doesn't check the true state of the file - it just
looks at its path: If the path ends with a configured archive file
suffix, isArchive()
always returns true
.
length()
always returns 0
if the path denotes a
valid archive file.
Otherwise, the return value of length()
depends on the
platform and file system, which is indicated by ?
.
For regular directories on Windows/NTFS for example, the return value
would be 0
.
isDirectory()
and isFile()
return false
, while exists()
returns
true
.default archive detector
.
API reference for configuring archive type
recognition
,
Serialized FormField Summary |
---|
Fields inherited from class java.io.File |
---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
Constructor Summary | |
---|---|
File(File template)
Copy constructor. |
|
File(File template,
ArchiveDetector detector)
Constructs a new File instance which may use the given
ArchiveDetector to detect any archive files in its path. |
|
File(File delegate,
File innerArchive,
ArchiveDetector detector)
This constructor is not for public use - do not use it! |
|
File(File template,
File delegate,
File enclArchive)
This constructor is not for public use - do not use it! |
|
File(File parent,
String child)
Equivalent to File(parent, child, null) . |
|
File(File parent,
String child,
ArchiveDetector detector)
Constructs a new File instance which uses the given
ArchiveDetector to detect any archive files in its path
and configure their parameters. |
|
File(String path)
Equivalent to File(path, getDefaultArchiveDetector()) . |
|
File(String path,
ArchiveDetector detector)
Constructs a new File instance which uses the given
ArchiveDetector to detect any archive files in its path. |
|
File(String parent,
String child)
Equivalent to File(parent, child, getDefaultArchiveDetector()) . |
|
File(String parent,
String child,
ArchiveDetector detector)
Constructs a new File instance which uses the given
ArchiveDetector to detect any archive files in its path. |
|
File(URI uri)
Constructs a new File instance from the given
uri . |
Method Summary | |
---|---|
boolean |
archiveCopyAllFrom(File src)
Recursively copies the file or directory src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllFrom(File src,
ArchiveDetector detector)
Recursively copies the file or directory src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllFrom(File src,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
Recursively copies the file or directory src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllTo(File dst)
Recursively copies this file or directory to the file or directory dst and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllTo(File dst,
ArchiveDetector detector)
Recursively copies this file or directory to the file or directory dst and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllTo(File dst,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
Recursively copies this file or directory to the file or directory dst and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyFrom(File src)
Copies the file src to this file and tries to preserve
all attributes of the source file to the destination file, too. |
boolean |
archiveCopyTo(File dst)
Copies this file to the file dst and tries to preserve
all attributes of the source
file to the destination file, too. |
boolean |
canRead()
|
boolean |
canWrite()
|
static void |
cat(InputStream in,
OutputStream out)
Copies all data from one stream to another without closing them. |
boolean |
catFrom(InputStream in)
Copies the input stream in to this file or
entry in an archive file without closing the input stream. |
boolean |
catTo(OutputStream out)
Copies this file or entry in an archive file to the output stream out without closing it. |
int |
compareTo(File other)
Compares this file's path to the given file's path. |
boolean |
contains(File file)
Returns true if and only if the path represented
by this instance contains the path represented by the specified
file ,
where a path is said to contain another path if and only
if it is equal or a parent of the other path. |
static boolean |
contains(File a,
File b)
Returns true if and only if the path represented
by a contains the path represented by b ,
where a path is said to contain another path if and only
if it is equal or a parent of the other path. |
boolean |
copyAllFrom(File src)
Recursively copies the file or directory src
to this file or directory. |
boolean |
copyAllFrom(File src,
ArchiveDetector detector)
Recursively copies the file or directory src
to this file or directory. |
boolean |
copyAllFrom(File src,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
Recursively copies the file or directory src
to this file or directory. |
boolean |
copyAllTo(File dst)
Recursively copies this file or directory to the file or directory dst . |
boolean |
copyAllTo(File dst,
ArchiveDetector detector)
Recursively copies this file or directory to the file or directory dst . |
boolean |
copyAllTo(File dst,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
Recursively copies this file or directory to the file or directory dst . |
boolean |
copyFrom(File src)
Copies the file src to this file. |
boolean |
copyFrom(InputStream in)
Copies the input stream in to this file and closes it. |
boolean |
copyTo(File dst)
Copies this file to the file dst . |
boolean |
copyTo(OutputStream out)
Copies this file to the output stream out and closes it. |
static void |
cp_p(File src,
File dst)
Copies src to dst and tries to preserve
all attributes of the source file to the destination file, too. |
static void |
cp(File src,
File dst)
Copies src to dst . |
static void |
cp(InputStream in,
OutputStream out)
Copies the input stream in to the output stream
out . |
boolean |
createNewFile()
Creates a new, empty file similar to its superclass implementation. |
boolean |
delete()
Deletes an archive entry, archive file or regular node in the real file system. |
boolean |
deleteAll()
Deletes the entire directory tree represented by this object, regardless whether this is a file or directory, whether the directory is empty or not or whether the file or directory is actually an archive file, an entry in an archive file or not enclosed in an archive file at all. |
void |
deleteOnExit()
|
boolean |
equals(Object other)
Tests this abstract path for equality with the given object. |
boolean |
exists()
This file system operation is virtually atomic. |
File |
getAbsoluteFile()
Behaves like the superclass implementation, but returns a new instance of this class, so you can safely cast it. |
String |
getAbsolutePath()
|
ArchiveDetector |
getArchiveDetector()
Returns the ArchiveDetector that was used to construct this
object - never null . |
File |
getCanonicalFile()
Behaves like the superclass implementation, but returns a new instance of this class, so you can safely cast it. |
String |
getCanonicalPath()
|
File |
getCanOrAbsFile()
This convenience method simply returns the canonical form of this abstract path or the normalized absolute form if resolving the prior fails. |
String |
getCanOrAbsPath()
This convenience method simply returns the canonical form of this abstract path or the normalized absolute form if resolving the prior fails. |
Icon |
getClosedIcon()
Returns an icon for this file or directory if it is in closed state for JFileTree
or null if the default should be used. |
static ArchiveDetector |
getDefaultArchiveDetector()
Returns the default ArchiveDetector to be used if no
archive detector is passed explicitly to the constructor of a
File instance. |
File |
getDelegate()
This method is not intended for public use! |
File |
getEnclArchive()
Returns the enclosing archive file in this path. |
String |
getEnclEntryName()
Returns the entry path in the enclosing archive file. |
File |
getInnerArchive()
Returns the innermost archive file in this path. |
String |
getInnerEntryName()
Returns the entry name in the innermost archive file. |
static ArchiveStatistics |
getLiveArchiveStatistics()
Returns a proxy instance which encapsulates live statistics about the total set of archives operated by this package. |
String |
getName()
|
File |
getNonArchivedParentFile()
Returns the first parent directory (starting from this file) which is not an archive file or a file located in an archive file. |
File |
getNormalizedAbsoluteFile()
Similar to getAbsoluteFile() , but removes any
". |
String |
getNormalizedAbsolutePath()
Similar to getAbsolutePath() , but removes any
". |
File |
getNormalizedFile()
Removes any ". |
String |
getNormalizedPath()
Removes any ". |
Icon |
getOpenIcon()
Returns an icon for this file or directory if it is in open state for JFileTree
or null if the default should be used. |
String |
getParent()
|
File |
getParentFile()
Behaves like the superclass implementation, but actually either returns null or a new instance of this class, so you can
safely cast it. |
String |
getPath()
|
File |
getTopLevelArchive()
Returns The top level archive file in the path or null
if this path does not denote an archive. |
int |
hashCode()
|
boolean |
isAbsolute()
|
boolean |
isArchive()
Returns true if and only if the path represented by this
instance denotes an archive file. |
boolean |
isDirectory()
Similar to its super class implementation, but returns true for a valid archive file. |
boolean |
isEntry()
Returns true if and only if the path represented by this
instance names an archive file as an ancestor. |
boolean |
isFile()
Similar to its super class implementation, but returns false for a valid archive file. |
boolean |
isFileSystemRoot()
Returns true if and only if this file denotes a file system
root or a UNC (if running on the Windows platform). |
boolean |
isHidden()
|
static boolean |
isLenient()
Returns the value of the class property lenient . |
boolean |
isParentOf(File file)
Returns true if and only if the path represented
by this instance is a direct or indirect parent of the path
represented by the specified file . |
boolean |
isUNC()
Returns true if and only if this file denotes a UNC. |
protected static boolean |
isUNC(String path)
Deprecated. This method will be made private in the next major version. |
long |
lastModified()
Returns a long value representing the time this file was
last modified, measured in milliseconds since the epoch (00:00:00 GMT,
January 1, 1970), or 0L if the file does not exist or if an
I/O error occurs or if this is a ghost directory in an archive file. |
long |
length()
Returns the (uncompressed) length of the file. |
String[] |
list()
Returns the names of the members in this directory in a newly created array. |
String[] |
list(FilenameFilter filenameFilter)
Returns the names of the members in this directory which are accepted by filenameFilter in a newly created array. |
File[] |
listFiles()
Equivalent to listFiles((FilenameFilter) null, getArchiveDetector()) . |
File[] |
listFiles(FileFactory factory)
Returns File objects for the members in this directory
in a newly created array. |
File[] |
listFiles(FileFilter fileFilter)
Equivalent to listFiles(fileFilter, getArchiveDetector()) . |
File[] |
listFiles(FileFilter fileFilter,
FileFactory factory)
Returns File objects for the members in this directory
which are accepted by fileFilter in a newly created array. |
File[] |
listFiles(FilenameFilter filenameFilter)
Equivalent to listFiles(filenameFilter, getArchiveDetector()) . |
File[] |
listFiles(FilenameFilter filenameFilter,
FileFactory factory)
Returns File objects for the members in this directory
which are accepted by filenameFilter in a newly created
array. |
boolean |
mkdir()
Creates a new, empty (virtual) directory similar to its superclass implementation. |
boolean |
mkdirs()
|
boolean |
renameTo(File dst)
Equivalent to renameTo(dst, getArchiveDetector()) . |
boolean |
renameTo(File dst,
ArchiveDetector detector)
Behaves similar to the super class, but renames this file or directory by recursively copying its data if this object or the dst
object is either an archive file or an entry located in an archive file. |
static void |
setDefaultArchiveDetector(ArchiveDetector detector)
This class property controls how archive files are recognized. |
boolean |
setLastModified(long time)
Sets the last modification of this file or (virtual) directory. |
static void |
setLenient(boolean lenient)
This class property controls whether (1) archive files and enclosed directories shall be created on the fly if they don't exist and (2) open archive entry streams should automatically be closed if they are only weakly reachable. |
boolean |
setReadOnly()
Like the super class implementation, but is aware of archive files in its path. |
String |
toString()
|
URI |
toURI()
|
URL |
toURL()
Deprecated. This method has been deprecated in JSE 6. |
static void |
umount()
Equivalent to umount(false, true, false, true) . |
static void |
umount(boolean closeStreams)
Equivalent to umount(false, closeStreams, false, closeStreams) . |
static void |
umount(boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams)
Updates all archive files in the real file system with the contents of their virtual file system, resets all cached state and deletes all temporary files. |
static void |
umount(File archive)
Equivalent to umount(archive, false, true, false, true) . |
static void |
umount(File archive,
boolean closeStreams)
Equivalent to umount(archive, false, closeStreams, false, closeStreams) . |
static void |
umount(File archive,
boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams)
Similar to umount(waitInputStreams, closeInputStreams, waitOutputStreams, closeOutputStreams) ,
but will only update the given archive and all its enclosed
(nested) archives. |
static void |
update()
Equivalent to update(false, true, false, true) . |
static void |
update(boolean closeStreams)
Equivalent to update(false, closeStreams, false, closeStreams) . |
static void |
update(boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams)
Like umount(waitInputStreams, closeInputStreams, waitOutputStreams, closeOutputStreams) ,
but may retain some temporary files in order to speed up subsequent
access to their archive files again. |
static void |
update(File archive)
Equivalent to update(archive, false, true, false, true) . |
static void |
update(File archive,
boolean closeStreams)
Equivalent to update(archive, false, closeStreams, false, closeStreams) . |
static void |
update(File archive,
boolean waitInputStreams,
boolean closeInputStreams,
boolean waitOutputStreams,
boolean closeOutputStreams)
Similar to update(waitInputStreams, closeInputStreams, waitOutputStreams, closeOutputStreams) ,
but will only update the given archive and all its enclosed
(nested) archives. |
Methods inherited from class java.io.File |
---|
canExecute, compareTo, createTempFile, createTempFile, getFreeSpace, getTotalSpace, getUsableSpace, listRoots, setExecutable, setExecutable, setReadable, setReadable, setWritable, setWritable |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public File(File template)
File(template, getDefaultArchiveDetector())
.
public File(File template, ArchiveDetector detector)
File
instance which may use the given
ArchiveDetector
to detect any archive files in its path.
template
- The file to use as a template. If this is an instance
of this class, its fields are copied and the
detector
parameter is ignored.detector
- The object used to detect any archive files in the path.
This parameter is ignored if template
is an
instance of this class.
Otherwise, it must not be null
.
NullPointerException
- If a required parameter is null
.public File(String path)
File(path, getDefaultArchiveDetector())
.
public File(String path, ArchiveDetector detector)
File
instance which uses the given
ArchiveDetector
to detect any archive files in its path.
path
- The path of the file.detector
- The object used to detect any archive files in the path.public File(String parent, String child)
File(parent, child, getDefaultArchiveDetector())
.
public File(String parent, String child, ArchiveDetector detector)
File
instance which uses the given
ArchiveDetector
to detect any archive files in its path.
parent
- The parent path as a String
.detector
- The object used to detect any archive files in the path.child
- The child path as a String
.public File(File parent, String child)
File(parent, child, null)
.
parent
- The parent directory as a File
instance.
If this parameter is an instance of this class, its
ArchiveDetector
is used to detect any archive files
in the path of this File
instance.
Otherwise, the getDefaultArchiveDetector()
is used.
This is used in order to make this File
instance
behave as if it had been created by one of the listFiles()
methods called on parent
instead.child
- The child path as a String
.public File(File parent, String child, ArchiveDetector detector)
File
instance which uses the given
ArchiveDetector
to detect any archive files in its path
and configure their parameters.
parent
- The parent directory as a File
instance.child
- The child path as a String
.detector
- The object used to detect any archive files in the path.
If this is null
and parent
is an
instance of this class, the archive detector is inherited from
this instance.
If this is null
and parent
is
not an instance of this class, the archive detector
returned by getDefaultArchiveDetector()
is used.
NullPointerException
- If child
is null
.public File(URI uri)
File
instance from the given
uri
. This method behaves similar to
new java.io.File(uri)
with the following
amendment:
If the URI matches the pattern
(jar:)*file:(path!/)*entry
, then the
constructed file object treats the URI like a (possibly ZIPped) file.
For example, in a Java application which is running from a JAR in the local file system you could use this constructor to arbitrarily access (and modify) all entries in the JAR file from which the application is currently running by using the following simple method:
public File getResourceAsFile(String resource) { URL url = getClass().getResource(resource); try { return new File(new URI(url.toExternalForm())); } catch (Exception notAJaredFileURI) { return null; } }The newly created
File
instance uses
ArchiveDetector.ALL
as its ArchiveDetector
.
uri
- an absolute, hierarchical URI with a scheme equal to
file
or jar
, a non-empty path component,
and undefined authority, query, and fragment components.
NullPointerException
- if uri
is null
.
IllegalArgumentException
- if the preconditions on the
parameter uri
do not hold.public File(File delegate, File innerArchive, ArchiveDetector detector)
FileFactory
public File(File template, File delegate, File enclArchive)
FileFactory
Method Detail |
---|
public static final void umount() throws ArchiveException
umount(false, true, false, true)
.
ArchiveException
public static final void umount(boolean closeStreams) throws ArchiveException
umount(false, closeStreams, false, closeStreams)
.
ArchiveException
public static final void umount(boolean waitInputStreams, boolean closeInputStreams, boolean waitOutputStreams, boolean closeOutputStreams) throws ArchiveException
For a detailed explanation of when and how to use this method, please refer to the section "Managing Archive File State" in the package summary.
waitInputStreams
- Suppose any other thread has still one or more
archive entry input streams open.
Then if and only if this parameter is true
, this
method will wait until all other threads have closed their
archive entry input streams.
Archive entry input streams opened (and not yet closed) by the
current thread are always ignored.
If the current thread gets interrupted while waiting, it will
stop waiting and proceed normally as if this parameter were
false
.
Be careful with this parameter value: If a stream has not been
closed because the client application does not always properly
close its streams, even on an IOException
(which is a
typical bug in many Java applications), then this method may
not return until the current thread gets interrupted!closeInputStreams
- Suppose there are any open input streams
for any archive entries because the application has forgot to
close all FileInputStream
objects or another thread is
still busy doing I/O on an archive.
Then if this parameter is true
, an update is forced
and an ArchiveBusyWarningException
is finally thrown to
indicate that any subsequent operations on these streams
will fail with an ArchiveEntryStreamClosedException
because they have been forced to close.
This may also be used to recover an application from a
FileBusyException
thrown by a constructor of
FileInputStream
or FileOutputStream
.
If this parameter is false
, the respective archive
file is not updated and an ArchiveBusyException
is thrown to indicate that the application must close all entry
input streams first.waitOutputStreams
- Similar to waitInputStreams
,
but applies to archive entry output streams instead.closeOutputStreams
- Similar to closeInputStreams
,
but applies to archive entry output streams instead.
If this parameter is true
, then
closeInputStreams
must be true
, too.
Otherwise, an IllegalArgumentException
is thrown.
ArchiveBusyWarningExcepion
- If an archive file has been updated
while the application is using any open streams to access it
concurrently.
These streams have been forced to close and the entries of
output streams may contain only partial data.
ArchiveWarningException
- If only warning conditions occur
throughout the course of this method which imply that the
respective archive file has been updated with constraints,
such as a failure to set the last modification time of the
archive file to the last modification time of its implicit
root directory.
ArchiveBusyException
- If an archive file could not get updated
because the application is using an open stream.
No data is lost and the archive file can still get updated by
calling this method again.
ArchiveException
- If any error conditions occur throughout the
course of this method which imply loss of data.
This usually means that at least one of the archive files
has been created externally and was corrupted or it cannot
get updated because the file system of the temp file or target
file folder is full.
IllegalArgumentException
- If closeInputStreams
is
false
and closeOutputStreams
is
true
.update(File)
,
update()
,
umount(File)
,
Managing Archive File Statepublic static final void umount(File archive) throws ArchiveException
umount(archive, false, true, false, true)
.
ArchiveException
public static final void umount(File archive, boolean closeStreams) throws ArchiveException
umount(archive, false, closeStreams, false, closeStreams)
.
ArchiveException
public static final void umount(File archive, boolean waitInputStreams, boolean closeInputStreams, boolean waitOutputStreams, boolean closeOutputStreams) throws ArchiveException
umount(waitInputStreams, closeInputStreams, waitOutputStreams, closeOutputStreams)
,
but will only update the given archive
and all its enclosed
(nested) archives.
If a client application needs to unmount an individual archive file, the following idiom can be used:
if (file.isArchive()
&& file.getEnclArchive()
== null) // filter top level archive
if (file.isDirectory()
) // ignore false positives
File.umount(File)
; // update archive and all enclosed archives
Again, this will also unmount all archive files which are located
within the archive file referred to by the file
instance.
archive
- A top level archive file.
NullPointerException
- If archive
is null
.
IllegalArgumentException
- If archive
is not an
archive or is enclosed in another archive (is not top level).
ArchiveException
update()
,
update(File)
,
umount()
,
Managing Archive File Statepublic static final void update() throws ArchiveException
update(false, true, false, true)
.
ArchiveException
public static final void update(boolean closeStreams) throws ArchiveException
update(false, closeStreams, false, closeStreams)
.
ArchiveException
public static final void update(boolean waitInputStreams, boolean closeInputStreams, boolean waitOutputStreams, boolean closeOutputStreams) throws ArchiveException
umount(waitInputStreams, closeInputStreams, waitOutputStreams, closeOutputStreams)
,
but may retain some temporary files in order to speed up subsequent
access to their archive files again.
Warning: Do not use this method unless you fully understand
its implications.
In particular, if the client application does not seem to recognize
changes made to archive files by
third parties,
replace the calls to this method with
umount(*)
.
public static final void update(File archive) throws ArchiveException
update(archive, false, true, false, true)
.
ArchiveException
public static final void update(File archive, boolean closeStreams) throws ArchiveException
update(archive, false, closeStreams, false, closeStreams)
.
ArchiveException
public static final void update(File archive, boolean waitInputStreams, boolean closeInputStreams, boolean waitOutputStreams, boolean closeOutputStreams) throws ArchiveException
update(waitInputStreams, closeInputStreams, waitOutputStreams, closeOutputStreams)
,
but will only update the given archive
and all its enclosed
(nested) archives.
archive
- A top level archive file.
NullPointerException
- If archive
is null
.
IllegalArgumentException
- If archive
is not an
archive or is enclosed in another archive (is not top level).
ArchiveException
update()
,
umount()
,
umount(File)
,
Managing Archive File Statepublic static final ArchiveStatistics getLiveArchiveStatistics()
Note that this method returns live statistics rather than real time statistics. So there may be a slight delay until the values returned reflect the actual state of this package. This delay increases if the system is under heavy load.
ArchiveStatistics
public static final boolean isLenient()
lenient
.
By default, this is the inverse of the boolean system property
de.schlichtherle.io.strict
.
In other words, this returns true
unless you set the
system property de.schlichtherle.io.strict
to
true
or call setLenient(false)
.
setLenient(boolean)
public static final void setLenient(boolean lenient)
true
.
If this class property is set to false
, then
the client application would have to call
new File("a/outer.zip/b/inner.zip").mkdirs()
before it could actually create the innermost "c" entry as a file
or directory.
More formally, before you can access a node in the virtual file system, all its parent directories must exist, including archive files. This emulates the behaviour of real file systems.
If this class property is set to true
however, then
any missing parent directories (including archive files) up to the
outermost archive file ("outer.zip") are created on the fly when using
operations to create the innermost element of the path ("c").
This allows applications to succeed when doing this:
new File("a/outer.zip/b/inner.zip/c").createNewFile()
,
or that:
new FileOutputStream("a/outer.zip/b/inner.zip/c")
.
Note that in any case the parent directory of the outermost archive file ("a"), must exist - TrueZIP does not create regular directories in the real file system on the fly.
IOException
occured while
accessing it.
However, open streams are a limited resource in any operating system
and may interfere with other services of the OS (on Windows, you can't
delete an open file).
This is called the "unclosed streams issue".
Likewise, in TrueZIP an unclosed archive entry stream may result in an
ArchiveBusy(Warning)?Exception
to be thrown when
umount()
or update()
is called.
In order to prevent this, TrueZIP's archive entry streams have a
Object.finalize()
method which closes an archive entry stream
if its garbage collected.
Now if this class property is set to false
, then
TrueZIP maintains a hard reference to all archive entry streams
until umount()
or update()
is called, which will deal
with them: If they are not closed, an
ArchiveBusy(Warning)?Exception
is thrown, depending on
the boolean parameters to these methods.
This setting is useful if you do not want to tolerate the "unclosed streams issue" in a client application.
If this class property is set to true
however, then
TrueZIP maintains only a weak reference to all archive entry streams.
This allows the garbage collector to finalize them before
umount()
or update()
is called.
The finalize() method will then close these archive entry streams,
which exempts them, from triggering an
ArchiveBusy(Warning)?Exception
on the next call to
umount()
or update()
.
However, closing an archive entry output stream this way may result
in loss of buffered data, so it's only a workaround for this issue.
Note that for the setting of this class property to take effect, any
change must be made before an archive is first accessed.
The setting will then persist until the archive is reset by the next
call to umount()
or update()
.
Historical note: Since TrueZIP 6.0 and before TrueZIP 6.4, archive entry streams were always only referenced by a weak reference by TrueZIP. This class property has been overloaded with this semantic in order to allow client applications to test for the "unclosed streams issue".
createNewFile()
,
FileInputStream
,
FileOutputStream
public static final ArchiveDetector getDefaultArchiveDetector()
ArchiveDetector
to be used if no
archive detector is passed explicitly to the constructor of a
File
instance.
This class property is initially set to
ArchiveDetector.DEFAULT
ArchiveDetector
,
setDefaultArchiveDetector(de.schlichtherle.io.ArchiveDetector)
public static final void setDefaultArchiveDetector(ArchiveDetector detector)
File
instance is created and no
ArchiveDetector
is provided to the constructor,
or when some method of this class are called which accept an
ArchiveDetector
parameter,
then this class property is used.
Changing this value affects all newly created File
instances, but not any existing ones.
detector
- The default ArchiveDetector
to use
for newly created File
instances which have not
been constructed with an explicit ArchiveDetector
parameter
NullPointerException
- If detector
is
null
.ArchiveDetector
,
getDefaultArchiveDetector()
,
Third Party
Access using different Archive Detectorspublic File getParentFile()
null
or a new instance of this class, so you can
safely cast it.
getParentFile
in class File
public File getNonArchivedParentFile()
public File getAbsoluteFile()
getAbsoluteFile
in class File
public File getNormalizedAbsoluteFile()
getAbsoluteFile()
, but removes any
"."
and ".."
directories
from the path wherever possible.
The result is similar to getCanonicalFile()
, but symbolic
links are not resolved.
This may be useful if getCanonicalFile()
throws an
IOException.
getCanonicalFile()
,
getNormalizedFile()
public String getNormalizedAbsolutePath()
getAbsolutePath()
, but removes any
"."
and ".."
directories
from the path wherever possible.
The result is similar to getCanonicalPath()
, but symbolic
links are not resolved.
This may be useful if getCanonicalPath()
throws an
IOException.
getCanonicalPath()
,
getNormalizedPath()
public File getNormalizedFile()
"."
and ".."
directories from the path wherever possible.
public String getNormalizedPath()
"."
, ".."
and empty directories
from the path wherever possible.
String
.public File getCanonicalFile() throws IOException
getCanonicalFile
in class File
IOException
public final File getCanOrAbsFile()
public String getCanOrAbsPath()
String
instance.public final boolean isArchive()
true
if and only if the path represented by this
instance denotes an archive file.
Whether or not this is true solely depends on the
ArchiveDetector
which was used to construct this
File
instance: If no ArchiveDetector
is
explicitly passed to the constructor,
getDefaultArchiveDetector()
is used.
Please note that no file system tests are performed!
If a client application needs to know whether this file really exists
as an archive file in the file system (and the correct password has
been entered in case it's a RAES encrypted ZIP file), it should
subsequently call isDirectory()
, too.
This will automount the virtual file system from the archive file and
return true
if and only if it's a valid archive file.
isDirectory()
,
isEntry()
public final boolean isEntry()
true
if and only if the path represented by this
instance names an archive file as an ancestor.
Whether or not this is true depends solely on the ArchiveDetector
used to construct this instance.
If no ArchiveDetector
was explicitly passed to the
constructor, getDefaultArchiveDetector()
is used.
Please note that no tests on the file's true state are performed!
If you need to know whether this file is really an entry in an archive
file (and the correct password has been entered in case it's a RAES
encrypted ZIP file), you should call
getParentFile()
.isDirectory()
, too.
This will automount the virtual file system from the archive file and
return true
if and only if it's a valid archive file.
isArchive()
public final File getInnerArchive()
null
otherwise.
This method always returns an undotified path, i.e. all
occurences of "."
and ".."
in the path are
removed according to their meaning wherever possible.
In order to support unlimited nesting levels, this method returns
a File
instance which again could be an entry within
another archive file.
public final String getInnerEntryName()
""
.
If this object is a file or directory located within an
archive file, then this method returns the relative path of
the entry in the enclosing archive file separated by the entry
separator character '/'
, or null
otherwise.
This method always returns an undotified path, i.e. all
occurences of "."
and ".."
in the path are
removed according to their meaning wherever possible.
public final File getEnclArchive()
null
otherwise.
This method always returns an undotified path, i.e. all
occurences of "."
and ".."
in the path are
removed according to their meaning wherever possible.
In order to support unlimited nesting levels, this method returns
a File
instance which again could be an entry within
another archive file.
public final String getEnclEntryName()
'/'
, or null
otherwise.
This method always returns an undotified path, i.e. all
occurences of "."
and ".."
in the path are
removed according to their meaning wherever possible.
public final ArchiveDetector getArchiveDetector()
ArchiveDetector
that was used to construct this
object - never null
.
public final File getDelegate()
java.io.File
object to which some
methods of this class delegate if this object does not represent an
archive file or an entry in an archive file.
This is required to support the stacking of file system implementations.
For example, javax.swing.JFileChooser
creates instances of
sun.awt.shell.ShellFolder
, which is a subclass of
java.io.File
, too.
These instances are wrapped as the delegate in instances of this
class when using de.schlichtherle.swing.JFileChooser
in
order to stack the functionality of these different file system
implementations.
In case you want to convert an instance of this class which recognized
the leaf of its path as an archive file to a file instance which
doesn't recognize this archive file, use the following code instead:
ArchiveDetector.NULL.createFile((File) file.getParentFile(), file.getName())
java.io.File
class or
one of its subclasses, but never an instance of this class or
its subclasses and never null
.public boolean isParentOf(File file)
true
if and only if the path represented
by this instance is a direct or indirect parent of the path
represented by the specified file
.
Note:
file
- The path to test for being a child of this path.
NullPointerException
- If the parameter is null
.public boolean contains(File file)
true
if and only if the path represented
by this instance contains the path represented by the specified
file
,
where a path is said to contain another path if and only
if it is equal or a parent of the other path.
Note:
file
- The path to test for being contained by this path.
NullPointerException
- If the parameter is null
.public static final boolean contains(File a, File b)
true
if and only if the path represented
by a
contains the path represented by b
,
where a path is said to contain another path if and only
if it is equal or a parent of the other path.
Note:
a
- The path to test for containing b
.b
- The path to test for being contained by a
.
NullPointerException
- If any parameter is null
.public boolean isFileSystemRoot()
true
if and only if this file denotes a file system
root or a UNC (if running on the Windows platform).
public boolean isUNC()
true
if and only if this file denotes a UNC.
Note that this may be only relevant on the Windows platform.
protected static final boolean isUNC(String path)
true
if and only if the given path is a UNC.
Note that this may be only relevant on the Windows platform.
public int hashCode()
hashCode
in class File
public boolean equals(Object other)
true
if and only if the argument is not
null
and is an abstract path that denotes the same
abstract path for a file or directory as this abstract path.
If the given file is not an instance of this class, the call is
forwarded to the superclass in order to ensure the required symmetry
of Object.equals(Object)
.
Otherwise, whether or not two abstract paths are equal depends upon the underlying operating and file system: On UNIX systems, alphabetic case is significant in comparing paths. On Microsoft Windows systems it is not unless the path denotes an entry in an archive file. In the latter case, the left part of the path up to the (leftmost) archive file is compared ignoring case while the remainder (the entry name) is compared considering case. This case distinction allows an application on Windows to deal with archive files generated on other platforms which may contain different entry with names that just differ in case (like e.g. hello.txt and HELLO.txt).
Thus, on Windows the following assertions all succeed:
File a, b; a = new File("c:\\any.txt"); b = new File("C:\\ANY.TXT"); assert a.equals(b); assert b.equals(a); a = new File("c:\\any.zip\\test.txt"), b = new File("C:\\ANY.ZIP\\test.txt"); assert a.equals(b); assert b.equals(a); a = new File("c:/any.zip/test.txt"); b = new File("C:\\ANY.ZIP\\test.txt"); assert a.equals(b); assert b.equals(a); a = new File("c:\\any.zip\\test.txt"); b = new File("C:/ANY.ZIP/test.txt"); assert a.equals(b); assert b.equals(a); a = new File("c:/any.zip/test.txt"); b = new File("C:/ANY.ZIP/test.txt"); assert a.equals(b); assert b.equals(a); a = new File("\\\\localhost\\any.zip\\test.txt"); b = new File("\\\\LOCALHOST\\ANY.ZIP\\test.txt"); assert a.equals(b); assert b.equals(a); a = new File("//localhost/any.zip/test.txt"); b = new File("\\\\LOCALHOST\\ANY.ZIP\\test.txt"); assert a.equals(b); assert b.equals(a); a = new File("\\\\localhost\\any.zip\\test.txt"); b = new File("//LOCALHOST/ANY.ZIP/test.txt"); assert a.equals(b); assert b.equals(a); a = new File("//localhost/any.zip/test.txt"); b = new File("//LOCALHOST/ANY.ZIP/test.txt"); assert a.equals(b); assert b.equals(a); a = new File("c:\\any.zip\\test.txt"); b = new File("c:\\any.zip\\TEST.TXT"); assert !a.equals(b); // two different entries in same ZIP file! assert !b.equals(a);
equals
in class File
other
- The object to be compared with this abstract path.
true
if and only if the objects are equal,
false
otherwiseFile.compareTo(Object)
,
Object.equals(Object)
public int compareTo(File other)
If the given file is not an instance of this class, the call is
forwarded to the superclass in order to ensure the required symmetry
of Comparable.compareTo(Object)
.
Otherwise, whether or not two abstract paths compare equal depends
upon the underlying operating and file system:
On UNIX platforms, alphabetic case is significant in comparing paths.
On the Windows platform it is not unless the path denotes
an entry in an archive file. In the latter case, the left part of the
path up to the (leftmost) archive file is compared in platform
dependent manner (hence ignoring case) while the remainder (the entry
name) is compared considering case.
This case distinction allows an application on the Windows platform to
deal with archive files generated on other platforms which may contain
different entries with names that just differ in case
(like e.g. "hello.txt"
and "HELLO.txt"
).
compareTo
in class File
other
- The file to be compared with this abstract path.
equals(Object)
,
Comparable.compareTo(Object)
public File getTopLevelArchive()
null
if this path does not denote an archive.
A top level archive is not enclosed in another archive.
If this does not return null
, this denotes the longest
part of the path which actually may (but does not need to) exist
as a regular file in the real file system.
public String getAbsolutePath()
getAbsolutePath
in class File
public String getCanonicalPath() throws IOException
getCanonicalPath
in class File
IOException
public String getName()
getName
in class File
public String getParent()
getParent
in class File
public String getPath()
getPath
in class File
public boolean isAbsolute()
isAbsolute
in class File
public boolean isHidden()
isHidden
in class File
public String toString()
toString
in class File
public URI toURI()
toURI
in class File
public URL toURL() throws MalformedURLException
toURL
in class File
MalformedURLException
File.toURL()
public boolean exists()
exists
in class File
public boolean isFile()
false
for a valid archive file.
This file system operation is virtually atomic.
isFile
in class File
public boolean isDirectory()
true
for a valid archive file.
In case a RAES encrypted ZIP file is tested which is accessed for the
first time, the user is prompted for the password (if password based
encryption is used).
Note that this is not the only method which would prompt the user for
a password: For example, length()
would prompt the user and
return 0
unless the user cancels the prompting or the
file is a false positive archive file.
This file system operation is virtually atomic.
isDirectory
in class File
public Icon getOpenIcon()
JFileTree
or null
if the default should be used.
public Icon getClosedIcon()
JFileTree
or null
if the default should be used.
public boolean canRead()
canRead
in class File
public boolean canWrite()
canWrite
in class File
public boolean setReadOnly()
true
if the entry exists and the
archive file was mounted read only.
This file system operation is virtually atomic.
setReadOnly
in class File
public long length()
0
in order
to correctly emulate virtual directories across all platforms.
In case a RAES encrypted ZIP file is tested which is accessed for the
first time, the user is prompted for the password (if password based
encryption is used).
Note that this is not the only method which would prompt the user for
a password: For example, isDirectory()
would prompt the user and
return true
unless the user cancels the prompting or the
file is a false positive archive file.
This file system operation is virtually atomic.
length
in class File
public long lastModified()
long
value representing the time this file was
last modified, measured in milliseconds since the epoch (00:00:00 GMT,
January 1, 1970), or 0L
if the file does not exist or if an
I/O error occurs or if this is a ghost directory in an archive file.
This file system operation is virtually atomic.
lastModified
in class File
public boolean setLastModified(long time)
Note that calling this method may incur a severe performance penalty
if the file is an entry in an archive file which has just been written
(such as after a normal copy operation).
If you want to copy a file's contents as well as its last modification
time, use archiveCopyFrom(java.io.File)
or
archiveCopyTo(java.io.File)
instead.
This file system operation is virtually atomic.
setLastModified
in class File
archiveCopyFrom(java.io.File)
,
archiveCopyTo(java.io.File)
,
Package description for more information
about ghost directoriespublic String[] list()
Note: Archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
list
in class File
public String[] list(FilenameFilter filenameFilter)
filenameFilter
in a newly created array.
The returned array is not sorted.
Note: Archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
list
in class File
null
if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.public File[] listFiles()
listFiles((FilenameFilter) null, getArchiveDetector())
.
listFiles
in class File
public File[] listFiles(FileFactory factory)
File
objects for the members in this directory
in a newly created array.
The returned array is not sorted.
Since TrueZIP 6.4, the returned array is an array of this class.
Previously, the returned array was an array of java.io.File
which solely contained instances of this class.
Note that archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
factory
- The factory used to create the member file of this
directory.
This could be an ArchiveDetector
in order to detect any
archives by the member file names.
null
if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.public File[] listFiles(FilenameFilter filenameFilter)
listFiles(filenameFilter, getArchiveDetector())
.
listFiles
in class File
public File[] listFiles(FilenameFilter filenameFilter, FileFactory factory)
File
objects for the members in this directory
which are accepted by filenameFilter
in a newly created
array.
The returned array is not sorted.
Since TrueZIP 6.4, the returned array is an array of this class.
Previously, the returned array was an array of java.io.File
which solely contained instances of this class.
Note that archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
factory
- The factory used to create the member file of this
directory.
This could be an ArchiveDetector
in order to detect any
archives by the member file names.
null
if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.public final File[] listFiles(FileFilter fileFilter)
listFiles(fileFilter, getArchiveDetector())
.
listFiles
in class File
public File[] listFiles(FileFilter fileFilter, FileFactory factory)
File
objects for the members in this directory
which are accepted by fileFilter
in a newly created array.
The returned array is not sorted.
Since TrueZIP 6.4, the returned array is an array of this class.
Previously, the returned array was an array of java.io.File
which solely contained instances of this class.
Note that archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
factory
- The factory used to create the member file of this
directory.
This could be an ArchiveDetector
in order to detect any
archives by the member file names.
null
if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.public boolean createNewFile() throws IOException
This file system operation is virtually atomic.
createNewFile
in class File
IOException
mkdir()
public boolean mkdirs()
mkdirs
in class File
public boolean mkdir()
isArchive()
returns
true
.
Example:
new File("archive.zip").mkdir();
Alternatively, archive files can be created on the fly by simply
creating their entries.
Example:
new FileOutputStream("archive.zip/README");
These examples assume TrueZIP's default configuration where ZIP file
recognition is enabled and isLenient()
returns true
.
This file system operation is virtually atomic.
mkdir
in class File
public boolean delete()
This file system operation is virtually atomic.
delete
in class File
deleteAll()
public boolean deleteAll()
This file system operation is not atomic.
public void deleteOnExit()
deleteOnExit
in class File
public final boolean renameTo(File dst)
renameTo(dst, getArchiveDetector())
.
renameTo
in class File
public boolean renameTo(File dst, ArchiveDetector detector)
dst
object is either an archive file or an entry located in an archive file.
Hence, in these cases only this file system operation is not
atomic.
detector
- The object used to detect any archive
files in the path and configure their parameters.public boolean copyFrom(InputStream in)
in
to this file and closes it.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | Always |
Direct Data Copying (DDC) | No |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean copyFrom(File src)
src
to this file.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean copyAllFrom(File src)
src
to this file or directory.
This version uses the ArchiveDetector
which was used to
construct this object to detect any archive files in the source
and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean copyAllFrom(File src, ArchiveDetector detector)
src
to this file or directory.
This version uses the given archive detector to detect any archive
files in the source and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.detector
- The object used to detect any archive files
in the source and destination directory trees.
NullPointerException
- If any parameter is null
.public boolean copyAllFrom(File src, ArchiveDetector srcDetector, ArchiveDetector dstDetector)
src
to this file or directory.
By using different ArchiveDetector
s for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector
could be
ArchiveDetector.DEFAULT
and dstDetector
must be
ArchiveDetector.NULL
) or changing the charset by configuring
a custom DefaultArchiveDetector
.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.srcDetector
- The object used to detect any archive files
in the source directory tree.dstDetector
- The object used to detect any archive files
in the destination directory tree.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean copyTo(OutputStream out)
out
and closes it.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | Always |
Direct Data Copying (DDC) | No |
Deletes partial written files on failure | n/a |
Deletes partial written directories on failure | n/a |
Atomic | No |
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean copyTo(File dst)
dst
.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.
true
if the file has been successfully copied.
NullPointerException
- If any parameter is null
.public boolean copyAllTo(File dst)
dst
.
This version uses the ArchiveDetector
which was used to
construct this object to detect any archive files in the source
and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean copyAllTo(File dst, ArchiveDetector detector)
dst
.
This version uses the given archive detector to detect any archive
files in the source and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.detector
- The object used to detect any archive files
in the source and destination directory trees.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean copyAllTo(File dst, ArchiveDetector srcDetector, ArchiveDetector dstDetector)
dst
.
By using different ArchiveDetector
s for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector
could be
ArchiveDetector.DEFAULT
and dstDetector
must be
ArchiveDetector.NULL
) or changing the charset by configuring
a custom DefaultArchiveDetector
.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.srcDetector
- The object used to detect any archive files
in the source directory tree.dstDetector
- The object used to detect any archive files
in the destination directory tree.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyFrom(File src)
src
to this file and tries to preserve
all attributes of the source file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyAllFrom(File src)
src
to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the ArchiveDetector
which was used to
construct this object to detect any archive files in the source
and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyAllFrom(File src, ArchiveDetector detector)
src
to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the given archive detector to detect any archive files in the source and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.detector
- The object used to detect any archive files
in the source and destination directory trees.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyAllFrom(File src, ArchiveDetector srcDetector, ArchiveDetector dstDetector)
src
to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
By using different ArchiveDetector
s for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector
could be
ArchiveDetector.DEFAULT
and dstDetector
must be
ArchiveDetector.NULL
) or changing the charset by configuring
a custom DefaultArchiveDetector
.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.srcDetector
- The object used to detect any archive files
in the source directory tree.dstDetector
- The object used to detect archive files
in the destination directory tree.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyTo(File dst)
dst
and tries to preserve
all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyAllTo(File dst)
dst
and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the ArchiveDetector
which was used to
construct this object to detect any archive files in the
source and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyAllTo(File dst, ArchiveDetector detector)
dst
and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the given archive detector to detect any archive files in the source and destination directory trees. This version uses the given archive detector to detect any archive files in the source and destination directory trees.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.detector
- The object used to detect any archive files
in the source and destination directory trees.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public boolean archiveCopyAllTo(File dst, ArchiveDetector srcDetector, ArchiveDetector dstDetector)
dst
and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
By using different ArchiveDetector
s for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector
could be
ArchiveDetector.DEFAULT
and dstDetector
must be
ArchiveDetector.NULL
) or changing the charset by configuring
a custom DefaultArchiveDetector
.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | Yes |
Reads and overwrites special files | No |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | No |
Atomic | No |
dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive files and entries
are only supported for instances of this class.srcDetector
- The object used to detect any archive files
in the source directory tree.dstDetector
- The object used to detect any archive files
in the destination directory tree.
true
if and only if the operation succeeded.
NullPointerException
- If any parameter is null
.public static final void cp(InputStream in, OutputStream out) throws IOException
in
to the output stream
out
.
Feature | Supported |
---|---|
Preserves file attributes | n/a |
Copies directories recursively | n/a |
Reads and overwrites special files | n/a |
Closes parameter streams | Always |
Direct Data Copying (DDC) | n/a |
Deletes partial written files on failure | n/a |
Deletes partial written directories on failure | n/a |
Atomic | No |
in
- The input stream.out
- The output stream.
InputIOException
- If copying the data fails because of an
IOException in the input stream.
IOException
- If copying the data fails because of an
IOException in the output stream.
NullPointerException
- If any parameter is null
.public static final void cp(File src, File dst) throws IOException
src
to dst
.
Feature | Supported |
---|---|
Preserves file attributes | None |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.
FileBusyException
- If an archive entry cannot get accessed
because the client application is trying to input or output
to the same archive file simultaneously and the respective
archive driver does not support this or the archive file needs
an automatic update which cannot get performed because the
client is still using other open FileInputStream
s or
FileOutputStream
s for other entries in the same archive
file.
FileNotFoundException
- If either the source or the destination
cannot get accessed.
InputIOException
- If copying the data fails because of an
IOException in the source.
IOException
- If copying the data fails because of an
IOException in the destination.
NullPointerException
- If any parameter is null
.public static final void cp_p(File src, File dst) throws IOException
src
to dst
and tries to preserve
all attributes of the source file to the destination file, too.
Currently, only the last modification time is preserved.
Feature | Supported |
---|---|
Preserves file attributes | Best effort |
Copies directories recursively | No |
Reads and overwrites special files | Yes |
Closes parameter streams | n/a |
Direct Data Copying (DDC) | Yes |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
src
- The source file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.dst
- The destination file. Note that although this just needs to
be a plain java.io.File
, archive entries are only
supported for instances of this class.
FileBusyException
- If an archive entry cannot get accessed
because the client application is trying to input or output
to the same archive file simultaneously and the respective
archive driver does not support this or the archive file needs
an automatic update which cannot get performed because the
client is still using other open FileInputStream
s or
FileOutputStream
s for other entries in the same archive
file.
FileNotFoundException
- If either the source or the destination
cannot get accessed.
InputIOException
- If copying the data fails because of an
IOException in the source.
IOException
- If copying the data fails because of an
IOException in the destination.
NullPointerException
- If any parameter is null
.public boolean catFrom(InputStream in)
in
to this file or
entry in an archive file without closing the input stream.
Feature | Supported |
---|---|
Preserves file attributes | n/a |
Copies directories recursively | n/a |
Reads and overwrites special files | Yes |
Closes parameter streams | Never |
Direct Data Copying (DDC) | n/a |
Deletes partial written files on failure | Yes |
Deletes partial written directories on failure | n/a |
Atomic | No |
in
- The input stream.
true
if and only if the operation succeeded.public boolean catTo(OutputStream out)
out
without closing it.
Feature | Supported |
---|---|
Preserves file attributes | n/a |
Copies directories recursively | n/a |
Reads and overwrites special files | Yes |
Closes parameter streams | Never |
Direct Data Copying (DDC) | n/a |
Deletes partial written files on failure | n/a |
Deletes partial written directories on failure | n/a |
Atomic | No |
out
- The output stream.
true
if and only if the operation succeeded.public static final void cat(InputStream in, OutputStream out) throws IOException
Feature | Supported |
---|---|
Preserves file attributes | n/a |
Copies directories recursively | n/a |
Reads and overwrites special files | n/a |
Closes parameter streams | Never |
Direct Data Copying (DDC) | n/a |
Deletes partial written files on failure | n/a |
Deletes partial written directories on failure | n/a |
Atomic | No |
in
- The input stream.out
- The output stream.
InputIOException
- If copying the data fails because of an
IOException in the input stream.
IOException
- If copying the data fails because of an
IOException in the output stream.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |