public class TarExtractor extends Object
ArchiveExtractor
, but is a bit faster
since it does not have to parse the Tar file before extracting it. (It parses
the Tar file while extracting it.)
Java's file system support sets a limit to how much entry metadata the extractor can extract. Currently, it only extracts the entry's last modification time.
The extraction process can be fine-tuned by configuring a
TarExtractSpecification
object and passing it to the extract method.
If the target is in a locking file system, the extractor automatically locks files and directories as required.
This class has a runnable main method. When run, it prints out the contents of a Tar file.
ArchiveExtractor
Constructor and Description |
---|
TarExtractor(File f)
Create a new Tar extractor for the supplied file.
|
TarExtractor(org.entityfs.ReadableFile f)
Create a new Tar extractor for the supplied file.
|
Modifier and Type | Method and Description |
---|---|
void |
extract(org.entityfs.DirectoryView target)
Extract the contents of the Tar file into a directory hierarchy starting
with the target directory.
|
void |
extract(org.entityfs.DirectoryView target,
TarExtractSpecification spec)
Extract the contents of the Tar file into a directory hierarchy starting
with the target directory.
|
void |
extract(File target)
Extract the contents of the Tar file into a directory hierarchy starting
with the target directory.
|
void |
extract(File target,
TarExtractSpecification spec)
Extract the contents of the Tar file into a directory hierarchy starting
with the target directory.
|
protected void |
extractInternal(org.entityfs.Directory target,
TarExtractSpecification spec) |
static void |
main(String[] args) |
public TarExtractor(org.entityfs.ReadableFile f)
Tip: GZipReadableFile
,
BZip2ReadableFile
and
LzmaReadableFile
can all be used here.
f
- The Tar file.public TarExtractor(File f)
f
- The Tar file.protected void extractInternal(org.entityfs.Directory target, TarExtractSpecification spec)
public void extract(org.entityfs.DirectoryView target) throws TarFileParseException, org.entityfs.support.exception.WrappedIOException
TarExtractSpecification
configuration.target
- The target directory.TarFileParseException
- On parse errors.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public void extract(org.entityfs.DirectoryView target, TarExtractSpecification spec) throws TarFileParseException, org.entityfs.support.exception.WrappedIOException
target
- The target directory. This may be null if spec
is
configured with a TarEntryExtractionStrategy
that does not use a
target directory.spec
- Configuration for the extraction operation.TarFileParseException
- On parse errors.org.entityfs.support.exception.WrappedIOException
- On I/O errors.public void extract(File target) throws org.entityfs.exception.EntityNotFoundException, org.entityfs.exception.NotADirectoryException, TarFileParseException, org.entityfs.support.exception.WrappedIOException
TarExtractSpecification
configuration.target
- The target directory.TarFileParseException
- On parse errors.org.entityfs.support.exception.WrappedIOException
- On I/O errors.org.entityfs.exception.EntityNotFoundException
- If the target directory does not exist.org.entityfs.exception.NotADirectoryException
- If the target is not a directory.public void extract(File target, TarExtractSpecification spec) throws org.entityfs.exception.EntityNotFoundException, org.entityfs.exception.NotADirectoryException, TarFileParseException, org.entityfs.support.exception.WrappedIOException
target
- The target directory. This may be null if spec
is
configured with a TarEntryExtractionStrategy
that does not use a
target directory.spec
- Configuration for the extraction operation.TarFileParseException
- On parse errors.org.entityfs.support.exception.WrappedIOException
- On I/O errors.org.entityfs.exception.EntityNotFoundException
- If the target directory does not exist.org.entityfs.exception.NotADirectoryException
- If the target is not a directory.public static void main(String[] args)