eap.tar
Class TarFile

java.lang.Object
  extended byeap.tar.TarFile
All Implemented Interfaces:
Archive

public class TarFile
extends Object
implements Archive

Reads tar format file. It will read both he older BSD tar format as well as the newer POSIX "USTAR" format.


Field Summary
static int BLOCK_SIZE
          The number of bytes in a tar block.
 
Constructor Summary
TarFile(InputStream in)
          Creates a new tar file which will read data from the given input stream.
 
Method Summary
 String getEntryName()
          Returns the name of the current archive entry.
 InputStream getStream()
          Returns a stream which will read the current file.
 TarHeader getTarHeader()
          Returns the TarHeader object for the current entry.
 boolean hasNextEntry()
          Checks if there are more entries in this archive.
 boolean isDirectory()
          Tests if thecurrent entry is a directory
 boolean isFile()
          Tests if the current entry is a regular file.
 void nextEntry()
          Advances to the next entry in the archive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE

public static final int BLOCK_SIZE
The number of bytes in a tar block. Files are padded to the next largest block, and the tar header occupies a single block.

See Also:
Constant Field Values
Constructor Detail

TarFile

public TarFile(InputStream in)
        throws IOException
Creates a new tar file which will read data from the given input stream. The created archive is positioned at the first entry.

Parameters:
in - The source of the tar formatted data.
Method Detail

nextEntry

public void nextEntry()
               throws IOException
Advances to the next entry in the archive. This will close the stream returned by a previous call to getStream().

Specified by:
nextEntry in interface Archive
Throws:
IOException

hasNextEntry

public boolean hasNextEntry()
Checks if there are more entries in this archive.

Specified by:
hasNextEntry in interface Archive
Returns:
true if there are more entries in this archive

getEntryName

public String getEntryName()
Returns the name of the current archive entry.

Specified by:
getEntryName in interface Archive
Returns:
The name of the current archive entry.

isDirectory

public boolean isDirectory()
Tests if thecurrent entry is a directory

Specified by:
isDirectory in interface Archive
Returns:
true if the current entry is a directory

isFile

public boolean isFile()
Tests if the current entry is a regular file.

Specified by:
isFile in interface Archive
Returns:
true if the current entry is a regular file.

getTarHeader

public TarHeader getTarHeader()
Returns the TarHeader object for the current entry. The header contains more information than is available through the generic Archive interface.

Returns:
The TarHeader object for the current entry.

getStream

public InputStream getStream()
Returns a stream which will read the current file. This method always returns the same input stream for the current file. This stream will be closed by a call to nextEntry().

Specified by:
getStream in interface Archive
Returns:
An input stream for reading the current file, or null if the current entry is not a file.