Package net.lingala.zip4j.model
Class ZipParameters
java.lang.Object
net.lingala.zip4j.model.ZipParameters
Encapsulates the parameters that that control how Zip4J encodes data
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Indicates the action to take when a symbolic link is added to the ZIP file -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AesKeyStrength
private AesVersion
private CompressionLevel
private CompressionMethod
private String
private boolean
private EncryptionMethod
private long
private long
private ExcludeFileFilter
private String
private String
private boolean
private long
private boolean
private boolean
private boolean
private String
private ZipParameters.SymbolicLinkAction
private boolean
private boolean
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a ZipParameters instance with default values; CompressionMethod.DEFLATE, CompressionLevel.NORMAL, EncryptionMethod.NONE, AesKeyStrength.KEY_STRENGTH_256, AesVerson.Two, SymbolicLinkAction.INCLUDE_LINKED_FILE_ONLY, readHiddenFiles is true, readHiddenFolders is true, includeRootInFolder is true, writeExtendedLocalFileHeader is true, overrideExistingFilesInZip is trueZipParameters
(ZipParameters zipParameters) Create a clone of given ZipParameters instance -
Method Summary
Modifier and TypeMethodDescriptionGet the key strength of the AES encryption keyGet the AES format version used for encryptionGet the compression level used to compress filesGet the compression method specified in this ZipParametersGet the encryption method used to encrypt fileslong
long
Returns the file exclusion filter that is currently being used when adding files/folders to zip fileGet the file commentlong
Get the last modified time to be used for files written to the ZIPGet the behavior when adding a symbolic linkboolean
Test if files files are to be encryptedboolean
Test if the parent folder of the added files will be included in the ZIPboolean
boolean
Test if hidden files will be included during folder recursionboolean
Test if hidden folders will be included during folder recursionboolean
Returns true if zip4j is using unix mode as default.boolean
void
setAesKeyStrength
(AesKeyStrength aesKeyStrength) Set the key strength of the AES encryption keyvoid
setAesVersion
(AesVersion aesVersion) Set the AES format version to use for encryptionvoid
setCompressionLevel
(CompressionLevel compressionLevel) Set the compression level used to compress filesvoid
setCompressionMethod
(CompressionMethod compressionMethod) Set the ZIP compression methodvoid
setDefaultFolderPath
(String defaultFolderPath) void
setEncryptFiles
(boolean encryptFiles) Set the flag indicating that files are to be encryptedvoid
setEncryptionMethod
(EncryptionMethod encryptionMethod) Set the encryption method used to encrypt filesvoid
setEntryCRC
(long entryCRC) void
setEntrySize
(long entrySize) void
setExcludeFileFilter
(ExcludeFileFilter excludeFileFilter) Set a filter to exclude any files from the list of files being added to zip.void
setFileComment
(String fileComment) Set the file commentvoid
setFileNameInZip
(String fileNameInZip) Set the filename that will be used to include a file into the ZIP file to a different name that given by the source filename added to the ZIP file.void
setIncludeRootFolder
(boolean includeRootFolder) Set the flag to indicate if the parent folder of added files will be included in the ZIPvoid
setLastModifiedFileTime
(long lastModifiedFileTime) Set the last modified time recorded in the ZIP file for the added files.void
setOverrideExistingFilesInZip
(boolean overrideExistingFilesInZip) Set the behavior if a file is added that already exists in the ZIP.void
setReadHiddenFiles
(boolean readHiddenFiles) Indicate if hidden files will be included during folder recursionvoid
setReadHiddenFolders
(boolean readHiddenFolders) Indicate if hidden folders will be included during folder recursionvoid
setRootFolderNameInZip
(String rootFolderNameInZip) Set the folder name that will be prepended to the filename in the ZIP.void
setSymbolicLinkAction
(ZipParameters.SymbolicLinkAction symbolicLinkAction) Set the behavior when adding a symbolic linkvoid
setUnixMode
(boolean unixMode) When set to true, zip4j uses unix mode as default when generating file headers.void
setWriteExtendedLocalFileHeader
(boolean writeExtendedLocalFileHeader)
-
Field Details
-
compressionMethod
-
compressionLevel
-
encryptFiles
private boolean encryptFiles -
encryptionMethod
-
readHiddenFiles
private boolean readHiddenFiles -
readHiddenFolders
private boolean readHiddenFolders -
aesKeyStrength
-
aesVersion
-
includeRootFolder
private boolean includeRootFolder -
entryCRC
private long entryCRC -
defaultFolderPath
-
fileNameInZip
-
lastModifiedFileTime
private long lastModifiedFileTime -
entrySize
private long entrySize -
writeExtendedLocalFileHeader
private boolean writeExtendedLocalFileHeader -
overrideExistingFilesInZip
private boolean overrideExistingFilesInZip -
rootFolderNameInZip
-
fileComment
-
symbolicLinkAction
-
excludeFileFilter
-
unixMode
private boolean unixMode
-
-
Constructor Details
-
ZipParameters
public ZipParameters()Create a ZipParameters instance with default values; CompressionMethod.DEFLATE, CompressionLevel.NORMAL, EncryptionMethod.NONE, AesKeyStrength.KEY_STRENGTH_256, AesVerson.Two, SymbolicLinkAction.INCLUDE_LINKED_FILE_ONLY, readHiddenFiles is true, readHiddenFolders is true, includeRootInFolder is true, writeExtendedLocalFileHeader is true, overrideExistingFilesInZip is true -
ZipParameters
Create a clone of given ZipParameters instance- Parameters:
zipParameters
- the ZipParameters instance to clone
-
-
Method Details
-
getCompressionMethod
Get the compression method specified in this ZipParameters- Returns:
- the ZIP compression method
-
setCompressionMethod
Set the ZIP compression method- Parameters:
compressionMethod
- the ZIP compression method
-
isEncryptFiles
public boolean isEncryptFiles()Test if files files are to be encrypted- Returns:
- true if files are to be encrypted
-
setEncryptFiles
public void setEncryptFiles(boolean encryptFiles) Set the flag indicating that files are to be encrypted- Parameters:
encryptFiles
- if true, files will be encrypted
-
getEncryptionMethod
Get the encryption method used to encrypt files- Returns:
- the encryption method
-
setEncryptionMethod
Set the encryption method used to encrypt files- Parameters:
encryptionMethod
- the encryption method to be used
-
getCompressionLevel
Get the compression level used to compress files- Returns:
- the compression level used to compress files
-
setCompressionLevel
Set the compression level used to compress files- Parameters:
compressionLevel
- the compression level used to compress files
-
isReadHiddenFiles
public boolean isReadHiddenFiles()Test if hidden files will be included during folder recursion- Returns:
- true if hidden files will be included when adding folders to the zip
-
setReadHiddenFiles
public void setReadHiddenFiles(boolean readHiddenFiles) Indicate if hidden files will be included during folder recursion- Parameters:
readHiddenFiles
- if true, hidden files will be included when adding folders to the zip
-
isReadHiddenFolders
public boolean isReadHiddenFolders()Test if hidden folders will be included during folder recursion- Returns:
- true if hidden folders will be included when adding folders to the zip
-
setReadHiddenFolders
public void setReadHiddenFolders(boolean readHiddenFolders) Indicate if hidden folders will be included during folder recursion- Parameters:
readHiddenFolders
- if true, hidden folders will be included when added folders to the zip
-
getAesKeyStrength
Get the key strength of the AES encryption key- Returns:
- the key strength of the AES encryption key
-
setAesKeyStrength
Set the key strength of the AES encryption key- Parameters:
aesKeyStrength
- the key strength of the AES encryption key
-
getAesVersion
Get the AES format version used for encryption- Returns:
- the AES format version used for encryption
-
setAesVersion
Set the AES format version to use for encryption- Parameters:
aesVersion
- the AES format version to use
-
isIncludeRootFolder
public boolean isIncludeRootFolder()Test if the parent folder of the added files will be included in the ZIP- Returns:
- true if the parent folder of the added files will be included into the zip
-
setIncludeRootFolder
public void setIncludeRootFolder(boolean includeRootFolder) Set the flag to indicate if the parent folder of added files will be included in the ZIP- Parameters:
includeRootFolder
- if true, the parent folder of added files will be included in the ZIP
-
getEntryCRC
public long getEntryCRC() -
setEntryCRC
public void setEntryCRC(long entryCRC) -
getDefaultFolderPath
-
setDefaultFolderPath
-
getFileNameInZip
-
setFileNameInZip
Set the filename that will be used to include a file into the ZIP file to a different name that given by the source filename added to the ZIP file. The filenameInZip must adhere to the ZIP filename specification, including the use of forward slash '/' as the directory separator, and it must also be a relative file. If the filenameInZip given is not null and not empty, the value specified by setRootFolderNameInZip() will be ignored.- Parameters:
fileNameInZip
- the filename to set in the ZIP. Use null or an empty String to set the default behavior
-
getLastModifiedFileTime
public long getLastModifiedFileTime()Get the last modified time to be used for files written to the ZIP- Returns:
- the last modified time in milliseconds since the epoch
-
setLastModifiedFileTime
public void setLastModifiedFileTime(long lastModifiedFileTime) Set the last modified time recorded in the ZIP file for the added files. If less than 0, the last modified time is cleared and the current time is used- Parameters:
lastModifiedFileTime
- the last modified time in milliseconds since the epoch
-
getEntrySize
public long getEntrySize() -
setEntrySize
public void setEntrySize(long entrySize) -
isWriteExtendedLocalFileHeader
public boolean isWriteExtendedLocalFileHeader() -
setWriteExtendedLocalFileHeader
public void setWriteExtendedLocalFileHeader(boolean writeExtendedLocalFileHeader) -
isOverrideExistingFilesInZip
public boolean isOverrideExistingFilesInZip() -
setOverrideExistingFilesInZip
public void setOverrideExistingFilesInZip(boolean overrideExistingFilesInZip) Set the behavior if a file is added that already exists in the ZIP.- Parameters:
overrideExistingFilesInZip
- if true, remove the existing file in the ZIP; if false do not add the new file
-
getRootFolderNameInZip
-
setRootFolderNameInZip
Set the folder name that will be prepended to the filename in the ZIP. This value is ignored if setFileNameInZip() is specified with a non-null, non-empty string.- Parameters:
rootFolderNameInZip
- the name of the folder to be prepended to the filename in the ZIP archive
-
getFileComment
Get the file comment- Returns:
- the file comment
-
setFileComment
Set the file comment- Parameters:
fileComment
- the file comment
-
getSymbolicLinkAction
Get the behavior when adding a symbolic link- Returns:
- the behavior when adding a symbolic link
-
setSymbolicLinkAction
Set the behavior when adding a symbolic link- Parameters:
symbolicLinkAction
- the behavior when adding a symbolic link
-
getExcludeFileFilter
Returns the file exclusion filter that is currently being used when adding files/folders to zip file- Returns:
- ExcludeFileFilter
-
setExcludeFileFilter
Set a filter to exclude any files from the list of files being added to zip. Mostly used when adding a folder to a zip, and if certain files have to be excluded from adding to the zip file. -
isUnixMode
public boolean isUnixMode()Returns true if zip4j is using unix mode as default. Returns False otherwise.- Returns:
- true if zip4j is using unix mode as default, false otherwise
-
setUnixMode
public void setUnixMode(boolean unixMode) When set to true, zip4j uses unix mode as default when generating file headers.- Parameters:
unixMode
-
-