org.at4j.tar
Class TarExtractor

java.lang.Object
  extended by org.at4j.tar.TarExtractor

public class TarExtractor
extends Object

This object is used to extract entries from a Tar archive. It does the same as the 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.

Since:
1.0
Author:
Karl Gustafsson
See Also:
ArchiveExtractor

Constructor Summary
TarExtractor(File f)
          Create a new Tar extractor for the supplied file.
TarExtractor(ReadableFile f)
          Create a new Tar extractor for the supplied file.
 
Method Summary
 void extract(DirectoryView target)
          Extract the contents of the Tar file into a directory hierarchy starting with the target directory.
 void extract(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(Directory target, TarExtractSpecification spec)
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TarExtractor

public TarExtractor(ReadableFile f)
Create a new Tar extractor for the supplied file.

Tip: GZipReadableFile, BZip2ReadableFile and LzmaReadableFile can all be used here.

Parameters:
f - The Tar file.

TarExtractor

public TarExtractor(File f)
Create a new Tar extractor for the supplied file.

Parameters:
f - The Tar file.
Method Detail

extractInternal

protected void extractInternal(Directory target,
                               TarExtractSpecification spec)

extract

public void extract(DirectoryView target)
             throws TarFileParseException,
                    WrappedIOException
Extract the contents of the Tar file into a directory hierarchy starting with the target directory. This method will use the default TarExtractSpecification configuration.

Parameters:
target - The target directory.
Throws:
TarFileParseException - On parse errors.
WrappedIOException - On I/O errors.

extract

public void extract(DirectoryView target,
                    TarExtractSpecification spec)
             throws TarFileParseException,
                    WrappedIOException
Extract the contents of the Tar file into a directory hierarchy starting with the target directory.

Parameters:
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.
Throws:
TarFileParseException - On parse errors.
WrappedIOException - On I/O errors.

extract

public void extract(File target)
             throws EntityNotFoundException,
                    NotADirectoryException,
                    TarFileParseException,
                    WrappedIOException
Extract the contents of the Tar file into a directory hierarchy starting with the target directory. This method will use the default TarExtractSpecification configuration.

Parameters:
target - The target directory.
Throws:
TarFileParseException - On parse errors.
WrappedIOException - On I/O errors.
EntityNotFoundException - If the target directory does not exist.
NotADirectoryException - If the target is not a directory.

extract

public void extract(File target,
                    TarExtractSpecification spec)
             throws EntityNotFoundException,
                    NotADirectoryException,
                    TarFileParseException,
                    WrappedIOException
Extract the contents of the Tar file into a directory hierarchy starting with the target directory.

Parameters:
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.
Throws:
TarFileParseException - On parse errors.
WrappedIOException - On I/O errors.
EntityNotFoundException - If the target directory does not exist.
NotADirectoryException - If the target is not a directory.

main

public static void main(String[] args)