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 enumIndicates the action to take when a symbolic link is added to the ZIP file -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AesKeyStrengthprivate AesVersionprivate CompressionLevelprivate CompressionMethodprivate Stringprivate booleanprivate EncryptionMethodprivate longprivate longprivate ExcludeFileFilterprivate Stringprivate Stringprivate booleanprivate longprivate booleanprivate booleanprivate booleanprivate Stringprivate ZipParameters.SymbolicLinkActionprivate booleanprivate 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 fileslonglongReturns the file exclusion filter that is currently being used when adding files/folders to zip fileGet the file commentlongGet the last modified time to be used for files written to the ZIPGet the behavior when adding a symbolic linkbooleanTest if files files are to be encryptedbooleanTest if the parent folder of the added files will be included in the ZIPbooleanbooleanTest if hidden files will be included during folder recursionbooleanTest if hidden folders will be included during folder recursionbooleanReturns true if zip4j is using unix mode as default.booleanvoidsetAesKeyStrength(AesKeyStrength aesKeyStrength) Set the key strength of the AES encryption keyvoidsetAesVersion(AesVersion aesVersion) Set the AES format version to use for encryptionvoidsetCompressionLevel(CompressionLevel compressionLevel) Set the compression level used to compress filesvoidsetCompressionMethod(CompressionMethod compressionMethod) Set the ZIP compression methodvoidsetDefaultFolderPath(String defaultFolderPath) voidsetEncryptFiles(boolean encryptFiles) Set the flag indicating that files are to be encryptedvoidsetEncryptionMethod(EncryptionMethod encryptionMethod) Set the encryption method used to encrypt filesvoidsetEntryCRC(long entryCRC) voidsetEntrySize(long entrySize) voidsetExcludeFileFilter(ExcludeFileFilter excludeFileFilter) Set a filter to exclude any files from the list of files being added to zip.voidsetFileComment(String fileComment) Set the file commentvoidsetFileNameInZip(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.voidsetIncludeRootFolder(boolean includeRootFolder) Set the flag to indicate if the parent folder of added files will be included in the ZIPvoidsetLastModifiedFileTime(long lastModifiedFileTime) Set the last modified time recorded in the ZIP file for the added files.voidsetOverrideExistingFilesInZip(boolean overrideExistingFilesInZip) Set the behavior if a file is added that already exists in the ZIP.voidsetReadHiddenFiles(boolean readHiddenFiles) Indicate if hidden files will be included during folder recursionvoidsetReadHiddenFolders(boolean readHiddenFolders) Indicate if hidden folders will be included during folder recursionvoidsetRootFolderNameInZip(String rootFolderNameInZip) Set the folder name that will be prepended to the filename in the ZIP.voidsetSymbolicLinkAction(ZipParameters.SymbolicLinkAction symbolicLinkAction) Set the behavior when adding a symbolic linkvoidsetUnixMode(boolean unixMode) When set to true, zip4j uses unix mode as default when generating file headers.voidsetWriteExtendedLocalFileHeader(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
-
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-
-