2.17.2: 2011-06-17

net.sf.basedb.util.zip
Class TarFilePacker

java.lang.Object
  extended by net.sf.basedb.util.zip.TarFilePacker
All Implemented Interfaces:
FilePacker
Direct Known Subclasses:
Bzip2FilePacker, GzipFilePacker

public class TarFilePacker
extends Object
implements FilePacker

This class packs files into a TAR archive.

Version:
2.4
Author:
martin, Nicklas
Last modified
$Date: 2007-07-11 15:45:01 +0200 (Mon, 02 Jul 2007) $

Field Summary
private  com.ice.tar.TarOutputStream tar
           
 
Constructor Summary
TarFilePacker()
          Creates a new TarFilePacker.
 
Method Summary
 void close()
          Finish the TAR file.
 String getDescription()
          Get a short description of this file format that is suitable for display in selection list boxes.
 String getFileExtension()
          Gets the extension that files, packed with this tool, should have, for example, zip or tar.gz Don't include the first dot!
 String getMimeType()
          Gets the MIME type to give compressed files from this packer
 void pack(String entryName, InputStream in, long size, long lastModified)
          Create a new TarEntry and write the compressed data to it.
 void setOutputStream(OutputStream out)
          Wrap the output stream in a TarOutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tar

private com.ice.tar.TarOutputStream tar
Constructor Detail

TarFilePacker

public TarFilePacker()
Creates a new TarFilePacker.

Method Detail

getDescription

public String getDescription()
Description copied from interface: FilePacker
Get a short description of this file format that is suitable for display in selection list boxes.

Specified by:
getDescription in interface FilePacker
Returns:
"TAR-archive (.tar)"

getFileExtension

public String getFileExtension()
Description copied from interface: FilePacker
Gets the extension that files, packed with this tool, should have, for example, zip or tar.gz Don't include the first dot!

Specified by:
getFileExtension in interface FilePacker
Returns:
"tar"

getMimeType

public String getMimeType()
Description copied from interface: FilePacker
Gets the MIME type to give compressed files from this packer

Specified by:
getMimeType in interface FilePacker
Returns:
"application/x-tar"

setOutputStream

public void setOutputStream(OutputStream out)
                     throws IOException
Wrap the output stream in a TarOutputStream.

Specified by:
setOutputStream in interface FilePacker
Parameters:
out - The output stream to write to
Throws:
IOException - If there is an error setting the output stream

pack

public void pack(String entryName,
                 InputStream in,
                 long size,
                 long lastModified)
          throws IOException
Create a new TarEntry and write the compressed data to it.

Specified by:
pack in interface FilePacker
Parameters:
entryName - The name of the packed resource, including path information
in - The input stream to read uncompressed data from, or null if the entry represents a directory
size - The number of bytes of uncompressed data
lastModified - The time the contents was last modified, or 0 if not known
Throws:
IOException - If there are any errors when reading or writing

close

public void close()
           throws IOException
Finish the TAR file.

Specified by:
close in interface FilePacker
Throws:
IOException - If there are any errors

2.17.2: 2011-06-17