Class ZipParameters


  • public class ZipParameters
    extends Object
    Encapsulates the parameters that that control how Zip4J encodes data
    • Constructor Detail

      • 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

        public ZipParameters​(ZipParameters zipParameters)
        Create a clone of given ZipParameters instance
        Parameters:
        zipParameters - the ZipParameters instance to clone
    • Method Detail

      • getCompressionMethod

        public CompressionMethod getCompressionMethod()
        Get the compression method specified in this ZipParameters
        Returns:
        the ZIP compression method
      • setCompressionMethod

        public void setCompressionMethod​(CompressionMethod compressionMethod)
        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

        public EncryptionMethod getEncryptionMethod()
        Get the encryption method used to encrypt files
        Returns:
        the encryption method
      • setEncryptionMethod

        public void setEncryptionMethod​(EncryptionMethod encryptionMethod)
        Set the encryption method used to encrypt files
        Parameters:
        encryptionMethod - the encryption method to be used
      • getCompressionLevel

        public CompressionLevel getCompressionLevel()
        Get the compression level used to compress files
        Returns:
        the compression level used to compress files
      • setCompressionLevel

        public void setCompressionLevel​(CompressionLevel compressionLevel)
        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

        public AesKeyStrength getAesKeyStrength()
        Get the key strength of the AES encryption key
        Returns:
        the key strength of the AES encryption key
      • setAesKeyStrength

        public void setAesKeyStrength​(AesKeyStrength aesKeyStrength)
        Set the key strength of the AES encryption key
        Parameters:
        aesKeyStrength - the key strength of the AES encryption key
      • getAesVersion

        public AesVersion getAesVersion()
        Get the AES format version used for encryption
        Returns:
        the AES format version used for encryption
      • setAesVersion

        public void setAesVersion​(AesVersion aesVersion)
        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

        public String getDefaultFolderPath()
      • setDefaultFolderPath

        public void setDefaultFolderPath​(String defaultFolderPath)
      • getFileNameInZip

        public String getFileNameInZip()
      • setFileNameInZip

        public void 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. 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

        public String getRootFolderNameInZip()
      • setRootFolderNameInZip

        public void setRootFolderNameInZip​(String rootFolderNameInZip)
        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

        public String getFileComment()
        Get the file comment
        Returns:
        the file comment
      • setFileComment

        public void setFileComment​(String fileComment)
        Set the file comment
        Parameters:
        fileComment - the file comment
      • getSymbolicLinkAction

        public ZipParameters.SymbolicLinkAction getSymbolicLinkAction()
        Get the behavior when adding a symbolic link
        Returns:
        the behavior when adding a symbolic link
      • setSymbolicLinkAction

        public void setSymbolicLinkAction​(ZipParameters.SymbolicLinkAction symbolicLinkAction)
        Set the behavior when adding a symbolic link
        Parameters:
        symbolicLinkAction - the behavior when adding a symbolic link
      • getExcludeFileFilter

        public ExcludeFileFilter getExcludeFileFilter()
        Returns the file exclusion filter that is currently being used when adding files/folders to zip file
        Returns:
        ExcludeFileFilter
      • setExcludeFileFilter

        public void setExcludeFileFilter​(ExcludeFileFilter excludeFileFilter)
        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 -