Spreadsheet Toolkit

corpus.fileIO
Class Zip

java.lang.Object
  |
  +--corpus.fileIO.Zip

public class Zip
extends java.lang.Object

http://www.javaworld.com/javaworld/jw-11-1998/jw-11-howto-p2.html

See Also:
ZipInfo, Unzip, FileIO.object_to_byteA_zip(Object)

Constructor Summary
Zip(java.io.OutputStream ps)
          The zipfile will be written to the supplied OutputStream
Zip(java.lang.String[] paths, java.lang.String zipfilename)
          Given an array of file paths, this constructor will create a zipfile containing them and write it out to the filename.
 
Method Summary
 void add(byte[] data, java.lang.String name, long lastModified)
          Adds a single new entry to the current Zip File.
 void add(java.lang.Object object, java.lang.String name)
          Compresses and object into the current zip file.
 void add(java.lang.String path)
          Adds a new entry to the Zip File.
 void close()
          Should be done after all entries have been added.
static byte[] compress(byte[] data)
          Given a byte array will return a zip compressed version.
static void compressDirectory(Directory dir)
          Will compress all the files in a directory and store them in a zip file in the directories parent.
static void main(java.lang.String[] rgstring)
          Run some tests and examples.
 void setup()
          Create the ZipOutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Zip

public Zip(java.io.OutputStream ps)
The zipfile will be written to the supplied OutputStream


Zip

public Zip(java.lang.String[] paths,
           java.lang.String zipfilename)
    throws java.io.FileNotFoundException
Given an array of file paths, this constructor will create a zipfile containing them and write it out to the filename.

Parameters:
paths - the string array of file paths to compress
zipfilename - the name of the file to output to. .zip will automagically be appended.
Method Detail

compressDirectory

public static void compressDirectory(Directory dir)
Will compress all the files in a directory and store them in a zip file in the directories parent.

Parameters:
dir - Path to the directory to compress.

setup

public void setup()
Create the ZipOutputStream


add

public void add(java.lang.String path)
         throws java.io.FileNotFoundException,
                java.io.IOException
Adds a new entry to the Zip File.

java.io.FileNotFoundException
java.io.IOException

add

public void add(java.lang.Object object,
                java.lang.String name)
         throws java.io.IOException
Compresses and object into the current zip file. The lastModified will be set as the current time.

Parameters:
object - The object to compress
name - The name of the object
java.io.IOException

add

public void add(byte[] data,
                java.lang.String name,
                long lastModified)
         throws java.io.IOException
Adds a single new entry to the current Zip File.

Parameters:
data - The data to be compressed in the zip file.
name - The name to assign to the data
lastModified - When the data was last modified
java.io.IOException

close

public void close()
           throws java.io.IOException
Should be done after all entries have been added.

java.io.IOException

compress

public static byte[] compress(byte[] data)
                       throws java.io.IOException
Given a byte array will return a zip compressed version.

java.io.IOException

main

public static void main(java.lang.String[] rgstring)
                 throws java.lang.Exception
Run some tests and examples.

java.lang.Exception

Spreadsheet Toolkit

Project Home Page