com.jfw.file
Class ZipFile

java.lang.Object
  extended by com.jfw.file.ZipFile

public final class ZipFile
extends java.lang.Object

Create a zip file.
You can encypt the generated zip file if you set the encryption key using the method setKey4Encryption(java.lang.String) before to use the create() method.
This is a proprietary encryption method.


Constructor Summary
ZipFile(java.lang.String name)
          Create an instance.
ZipFile(java.lang.String path, java.lang.String name)
          Create an instance.
 
Method Summary
 void addFile(java.lang.String name)
          Add a file to zip.
 void addFile(java.lang.String name, java.lang.String nameInZip)
          Add a file to zip.
 void create()
          Create the zip file.
 void encrypt(java.lang.String file2Encrypt)
          Encrypt the generated zip file.
 java.lang.String getKey4Encryption()
          Get the encryption key.
 void setCompressionType(int compressionType)
          Set the compression method to use.
 void setKey4Encryption(java.lang.String key4Encryption)
          Set the encryption key of the zipped files.
 java.lang.String toString()
          Return log information relative of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZipFile

public ZipFile(java.lang.String name)
Create an instance.

Parameters:
name - path and name, with extension, of zip file.

ZipFile

public ZipFile(java.lang.String path,
               java.lang.String name)
Create an instance.

Parameters:
path - the path of the zip file.
name - name, with extension, of zip file.
Method Detail

setKey4Encryption

public void setKey4Encryption(java.lang.String key4Encryption)
Set the encryption key of the zipped files.

Parameters:
key4Encryption - the encryption key.

getKey4Encryption

public java.lang.String getKey4Encryption()
Get the encryption key.

Returns:
the encryption key.

setCompressionType

public void setCompressionType(int compressionType)
Set the compression method to use. Possible values are given from the static attributes of class java.util.zip.ZipOutputStream.STORED and java.util.zip.ZipOutputStream.DEFLATED.

Parameters:
compressionType -

addFile

public void addFile(java.lang.String name,
                    java.lang.String nameInZip)
             throws JFWGenericException
Add a file to zip.

Parameters:
name - name of zip file.
nameInZip - the path and name of file in zip.
Throws:
JFWGenericException

addFile

public void addFile(java.lang.String name)
             throws JFWGenericException
Add a file to zip.

Parameters:
name - name of zip file. This value will be used for read the file from the file system, so an absolute path must be given.
Throws:
JFWGenericException

create

public void create()
            throws JFWGenericException
Create the zip file.

Throws:
JFWGenericException

encrypt

public void encrypt(java.lang.String file2Encrypt)
             throws JFWGenericException
Encrypt the generated zip file. The new file name will be the name set in constructor plus the TMP_EXT string.

Throws:
JFWGenericException

toString

public java.lang.String toString()
Return log information relative of the object.

Overrides:
toString in class java.lang.Object
Returns:
log information relative of the object.