Java Tar Developer Reference
The
Java Tar pacakge
is written to be very similar to the
java.util.zip
package.
TarEntry
TarEntry
objects are similar to
ZipEntry
objects. They represent an item in a tar archive.
Typically, TarEntry's come from one of two places.
They can come from a TarInputStream.getNextEntry()
.
They can also come from a new TarEntry( java.io.File )
.
However, you can also construct a TarEntry providing only the
TarEntry's name. This allows you to construct TarEntry's that
will be written to a TarOutputStream from any InputStream source.
An example of this technique is used by the Giant Java Tree's
AutoRad server. You can
view the source code to PackageThread.java.
Use your browser's 'Find' command to locate the
writeTarArchive()
method.
TarHeader
TarHeader
objects are simply place holders (data structures) for the
header information of a TarEntry. Methods are provided for
parsing headers from tar archives, as well as generating
headers from file information.
TarInputStream
TarInputStream
is a subclass of
FilterInputStream.
TarInputStream is very similar to
ZipInputStream
in the way it presents the tar archive concept to you.
To read a tar archive, you open a TarInputStream, then loop
using getNextEntry()
, followed by a read()
of
the contents of the entry. The read method will return EOF (-1) at the
end of each entry, at which time you loop to the next entry.
TarOutputStream
TarOutputStream
is a subclass of
FilterOutputStream.
TarOutputStream is very similar to
ZipOutputStream
in the way it presents the tar archive concept to you.
To write a tar archive, you open a TarOutputStream, then loop
using putNextEntry()
, followed by a write()
of
the contents of the entry. Each putNextEntry call will effectively
define the end of the previous entry's contents.
TarArchive
TarArchive
objects represent an archive of files and directories represented
by TarEntry objects. Each TarEntry is delineated by a record
containing the entry's header, followed by the contents of the
object defined by the header. Directory entries can be explicitly
placed in a tar archive, or simply implied by the paths of the
file entries in the archive. When com.ice.tar.tar writes an archive,
it explicitly write each directory entry that it encounters when
recursing over a directory's subtree.
To write a tar archive, create a new TarArchive with an
OutputStream, then repeatedly call writeEntry() with TarEntry
objects created using the TarEntry( File ) constructor for
each top level item to be placed in the archive.
To extract the contents of a tar archive,
create a new TarArchive
with an InputStream, then call extractContents() with File
that indicates the destination extraction directory.
Please refer to the code for TarArchive.extractContents()
for the details of reading individual archive entries.
TarBuffer
TarBuffer
class is used to implement the blocked I/O of tar. This is done
to ensure that Java Tar is as compatible as possible with other
tar implementations.
Home
The Java Tar Home Page.
$Id: devref.html,v 1.1 2006/04/13 20:07:53 tom Exp $
Authored By Timothy Gerard Endres, time@dotfile.com
This work been placed into the public domain.