|
Java Tool Kit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectITT.WAFr.Utilities.ZipFile
The ZipFile class provides convenient methods to generate streaming files in ZIP file format.
A ZipFile object can contain multiple sub-file entries in any of the following formats:
Any number of files can be added to the ZipFile object via the numerous Add methods. When all files have been added, the Create method will generate the ZIP file and stream the resulting data to the specified OutputStream.
NOTE: Because the ZipFile class is streaming, none of the methods will throw exceptions. Any exception thrown would end the output stream and result in a partial or corrupted ZIP file. To combat this, the ZipFile class will exclude any failed sub-file entries.
It is not necessary to close the output stream or any added input streams, as the Create method will do so upon completion.
Upon completion of the Create method, various methods are available to retrieve resulting errors and statistics regarding the zipping process.
| Field Summary | |
static int |
BestCompression
|
static int |
BestSpeed
|
static int |
NoCompression
|
| Constructor Summary | |
ZipFile()
Constructs a new ZipFile object with a default compression level of zero (0), or NoCompression. |
|
ZipFile(int iCompression)
Constructs a new ZipFile object with a compression level of the specified integer from 0 - 9. |
|
| Method Summary | |
void |
Add(byte[] iFileContent,
String sFileName)
Adds the file represented by the specified byte array to the resulting ZIP file utilizing the specified file name. |
void |
Add(byte[] iFileContent,
String sFileName,
String sZipPath)
Adds the file represented by the specified byte array to the resulting ZIP file utilizing the specified file name. |
void |
Add(File oFile)
Adds the file represented by the specified File object to the resulting ZIP file. |
void |
Add(File oFile,
String sZipPath)
Adds the file represented by the specified File object to the resulting ZIP file. |
void |
Add(InputStream oFileInput,
String sFileName)
Adds the file represented by the specified InputStream to the resulting ZIP file utilizing the specified file name. |
void |
Add(InputStream oFileInput,
String sFileName,
String sZipPath)
Adds the file represented by the specified InputStream to the resulting ZIP file utilizing the specified file name. |
void |
Add(String sSourcePath)
Adds the file at the specified source path to the resulting ZIP file. |
void |
Add(String sSourcePath,
String sZipPath)
Adds the file at the specified source path to the resulting ZIP file. |
void |
Add(Upload.PostedFile oPostedFile)
Adds the file represented by the specified Upload.PostedFile object to the resulting ZIP file. |
void |
Add(Upload.PostedFile oPostedFile,
String sZipPath)
Adds the file represented by the specified Upload.PostedFile object to the resulting ZIP file. |
void |
Compression(int iCompression)
Set the compression level of the ZIP file with the specified integer parameter. |
void |
Create(OutputStream oOutput)
Creates a ZIP file with the added sub-file entries and streams the data to the specified output stream. |
int |
ErrorCount()
Retrieves the total number of errors that occurred during the zipping process. |
String[] |
ErrorLog()
Retrieves an array of error descriptions for each error that occurred during the zipping process. |
int |
FailedFileCount()
Retrieves the number of sub-file entries that failed to be added to the resulting ZIP file stream. |
double |
InputRate()
Retrieves the number of processed input data in Kilobytes per second, to the nearest tenth KB/s. |
double |
InputSize()
Retrieves the number of Kilobytes inputted and processed during the zipping process. |
double |
OutputRate()
Retrieves the number of processed output data in Kilobytes per second, to the nearest tenth KB/s. |
double |
OutputSize()
Retrieves the size of the ZIP file output stream in Kilobytes. |
double |
ProcessTime()
Retrieves the number of seconds, accurate to the millisecond, required to process the resulting ZIP stream. |
String |
Statistics()
Retrieves a formatted report of all errors and statistics that occurred during the zipping process. |
int |
ZippedFileCount()
Retrieves the number of sub-file entries successfully added and zipped to the resulting ZIP file stream. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int BestCompression
public static final int BestSpeed
public static final int NoCompression
| Constructor Detail |
public ZipFile()
ZipFile object with a default compression level of zero (0), or NoCompression.
ZipFile(int)public ZipFile(int iCompression)
ZipFile object with a compression level of the specified integer from 0 - 9.
A compression level less than 1 will result in the default compression level of NoCompression. Compression levels greater than 8 will result the in the maximum level of BestCompression.
iCompression - an integer from 0 - 9 representing the compression level of the ZIP file.ZipFile(),
Compression(int)| Method Detail |
public void Add(byte[] iFileContent,
String sFileName)
The sub-file entry will have no path and reside at the top level of the resulting ZIP file.
iFileContent - a byte array representing the content of the sub-file entry to be added to the ZIP file.sFileName - a String containing the name to use for the sub-file entry within the ZIP file.Add(byte[],String,String)
public void Add(byte[] iFileContent,
String sFileName,
String sZipPath)
The sub-file entry will reside within the specified relative path within the resulting ZIP file.
iFileContent - a byte array representing the content of the sub-file entry to be added to the ZIP file.sFileName - a String containing the name to use for the sub-file entry within the ZIP file.sZipPath - a String containing the relative path for the sub-file entry within the ZIP file.Add(byte[],String)public void Add(File oFile)
The sub-file entry will have no path and reside at the top level of the resulting ZIP file.
oFile - a File object representing the sub-file entry to be added to the ZIP file.Add(File,String)
public void Add(File oFile,
String sZipPath)
The sub-file entry will reside within the specified relative path within the resulting ZIP file.
oFile - a File object representing the sub-file entry to be added to the ZIP file.sZipPath - a String containing the relative path for the sub-file entry within the ZIP file.Add(File)
public void Add(InputStream oFileInput,
String sFileName)
The sub-file entry will have no path and reside at the top level of the resulting ZIP file.
oFileInput - an InputStream containing the content of the sub-file entry to be added to the ZIP file.sFileName - a String containing the name to use for the sub-file entry within the ZIP file.Add(InputStream,String,String)
public void Add(InputStream oFileInput,
String sFileName,
String sZipPath)
The sub-file entry will reside within the specified relative path within the resulting ZIP file.
oFileInput - an InputStream containing the content of the sub-file entry to be added to the ZIP file.sFileName - a String containing the name to use for the sub-file entry within the ZIP file.sZipPath - a String containing the relative path for the sub-file entry within the ZIP file.Add(InputStream,String)public void Add(String sSourcePath)
The sub-file entry will have no path and reside at the top level of the resulting ZIP file.
sSourcePath - a String specifying the path to the source file to be added to the ZIP file.Add(String,String)
public void Add(String sSourcePath,
String sZipPath)
The sub-file entry will reside within the specified relative path within the resulting ZIP file.
sSourcePath - a String specifying the path to the source file to be added to the ZIP file.sZipPath - a String containing the relative path for the sub-file entry within the ZIP file.Add(String)public void Add(Upload.PostedFile oPostedFile)
The sub-file entry will have no path and reside at the top level of the resulting ZIP file.
oPostedFile - an Upload.PostedFile object representing the sub-file entry to be added to the ZIP file.Add(Upload.PostedFile,String)
public void Add(Upload.PostedFile oPostedFile,
String sZipPath)
The sub-file entry will reside within the specified relative path within the resulting ZIP file.
oPostedFile - an Upload.PostedFile object representing the sub-file entry to be added to the ZIP file.sZipPath - a String containing the relative path for the sub-file entry within the ZIP file.Add(Upload.PostedFile)public void Compression(int iCompression)
A compression level less than 1 will result in the default compression level of NoCompression.
Compression levels greater than 8 will result the in the maximum level of BestCompression.
iCompression - an integer from 0 - 9 representing the compression level of the ZIP file.public void Create(OutputStream oOutput)
This method closes the specified output stream any input streams passed with the Add method.
oOutput - an OutputStream in which the method will write the processed data.public int ErrorCount()
ZippedFileCount(),
FailedFileCount()public String[] ErrorLog()
ErrorCount()public int FailedFileCount()
ZippedFileCount(),
ErrorCount()public double InputRate()
OutputRate()public double InputSize()
OutputSize()public double OutputRate()
InputRate()public double OutputSize()
InputSize()public double ProcessTime()
public String Statistics()
public int ZippedFileCount()
FailedFileCount(),
ErrorCount()
|
Java Tool Kit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||