Package net.sf.basedb.util.zip
Class ZipFilePacker
java.lang.Object
net.sf.basedb.util.zip.ZipFilePacker
- All Implemented Interfaces:
AutoCloseable
,FilePacker
This class packs files into a ZIP archive.
- Version:
- 2.4
- Author:
- Martin, Nicklas
- Last modified
- $Date$
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a new packer that compresses files with the zip format. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Finish the ZIP file.Get a short description of this file format that is suitable for display in selection list boxes.Gets the extension that files, packed with this tool, should have, for example,zip
ortar.gz
Don't include the first dot!Gets the MIME type to give compressed files from this packerGet the encyption password parameter.void
pack
(String entryName, InputStream in, long size, long lastModified) Create a new entry and write the compressed data to it.void
Wrap the output stream in aZipOutputStream
.void
setPassword
(String password) Set the password to use for encrypting the archive.boolean
Encryption is supported.
-
Field Details
-
zip
private net.lingala.zip4j.io.outputstream.ZipOutputStream zip -
password
-
-
Constructor Details
-
ZipFilePacker
public ZipFilePacker()Create a new packer that compresses files with the zip format.
-
-
Method Details
-
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 interfaceFilePacker
- Returns:
- Always "Zip-archive (.zip)"
-
getFileExtension
Description copied from interface:FilePacker
Gets the extension that files, packed with this tool, should have, for example,zip
ortar.gz
Don't include the first dot!- Specified by:
getFileExtension
in interfaceFilePacker
- Returns:
- Always "zip"
-
getMimeType
Description copied from interface:FilePacker
Gets the MIME type to give compressed files from this packer- Specified by:
getMimeType
in interfaceFilePacker
- Returns:
- Always "application/zip"
-
setOutputStream
Wrap the output stream in aZipOutputStream
.- Specified by:
setOutputStream
in interfaceFilePacker
- Parameters:
out
- The output stream to write to
-
supportsEncryption
public boolean supportsEncryption()Encryption is supported.- Specified by:
supportsEncryption
in interfaceFilePacker
- Since:
- 3.19.5
-
getPasswordParameter
Get the encyption password parameter.- Specified by:
getPasswordParameter
in interfaceFilePacker
- Since:
- 3.19.5
-
setPassword
Description copied from interface:FilePacker
Set the password to use for encrypting the archive. This method is only called if the implementation supports encryption and the user has entered a password.- Specified by:
setPassword
in interfaceFilePacker
- Since:
- 3.19.5
-
pack
Create a new entry and write the compressed data to it.- Specified by:
pack
in interfaceFilePacker
- Parameters:
entryName
- The name of the packed resource, including path informationin
- The input stream to read uncompressed data from, or null if the entry represents a directorysize
- The number of bytes of uncompressed datalastModified
- The time the contents was last modified, or 0 if not known- Throws:
IOException
- If there are any errors when reading or writing
-
close
Finish the ZIP file.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceFilePacker
- Throws:
IOException
- If there are any errors
-