SevenZipEntrySettings
Inheritance: java.lang.Object
public class SevenZipEntrySettings
Settings used to compress or decompress 7z entries.
Constructors
Constructor | Description |
---|---|
SevenZipEntrySettings() | Initializes a new instance of the SevenZipEntrySettings class. |
SevenZipEntrySettings(SevenZipCompressionSettings compressionSettings) | Initializes a new instance of the SevenZipEntrySettings class. |
SevenZipEntrySettings(SevenZipCompressionSettings compressionSettings, SevenZipEncryptionSettings encryptionSettings) | Initializes a new instance of the SevenZipEntrySettings class. |
Methods
Method | Description |
---|---|
getCompressHeader() | Gets value indicating whether to compress archive header. |
getCompressionSettings() | Gets settings for compression or decompression routine. |
getEncryptionSettings() | Gets settings for encryption or decryption. |
getSolid() | Gets value indicating whether to concatenate entries and treat them as a single data block. |
setCompressHeader(boolean value) | Sets value indicating whether to compress archive header. |
setSolid(boolean value) | Sets value indicating whether to concatenate entries and treat them as a single data block. |
SevenZipEntrySettings()
public SevenZipEntrySettings()
Initializes a new instance of the SevenZipEntrySettings class.
SevenZipEntrySettings(SevenZipCompressionSettings compressionSettings)
public SevenZipEntrySettings(SevenZipCompressionSettings compressionSettings)
Initializes a new instance of the SevenZipEntrySettings class.
Parameters:
Parameter | Type | Description |
---|---|---|
compressionSettings | SevenZipCompressionSettings | settings for compression. Pass null for default LZMA settings. |
Can be one of these:
- SevenZipLZMACompressionSettings
- SevenZipLZMA2CompressionSettings
- SevenZipBZip2CompressionSettings
- SevenZipPPMdCompressionSettings
- SevenZipStoreCompressionSettings |
SevenZipEntrySettings(SevenZipCompressionSettings compressionSettings, SevenZipEncryptionSettings encryptionSettings)
public SevenZipEntrySettings(SevenZipCompressionSettings compressionSettings, SevenZipEncryptionSettings encryptionSettings)
Initializes a new instance of the SevenZipEntrySettings class.
Parameters:
Parameter | Type | Description |
---|---|---|
compressionSettings | SevenZipCompressionSettings | settings for compression. Pass null for default LZMA settings. |
Can be one of these:
- SevenZipLZMACompressionSettings
- SevenZipLZMA2CompressionSettings
- SevenZipBZip2CompressionSettings
- SevenZipPPMdCompressionSettings
- SevenZipStoreCompressionSettings | | encryptionSettings | SevenZipEncryptionSettings | settings for encryption. Pass null if no need to encrypt or decrypt.
Can be only one:
getCompressHeader()
public final boolean getCompressHeader()
Gets value indicating whether to compress archive header.
This setting is equivalent -mhc=on
switch of 7-Zip tool. Currently, it is incompatible with header encryption.
Returns: boolean - value indicating whether to compress archive header
getCompressionSettings()
public final SevenZipCompressionSettings getCompressionSettings()
Gets settings for compression or decompression routine.
Returns: SevenZipCompressionSettings - settings for compression or decompression routine
getEncryptionSettings()
public final SevenZipEncryptionSettings getEncryptionSettings()
Gets settings for encryption or decryption. Settings of particular entry may vary.
The SevenZipAESEncryptionSettings is only option for 7z archives.
Returns: SevenZipEncryptionSettings - settings for encryption or decryption
getSolid()
public final boolean getSolid()
Gets value indicating whether to concatenate entries and treat them as a single data block.
The following example shows how to compress a directory to solid 7z archive with LZMA2 compression without encryption.
try (FileOutputStream sevenZipFile = new FileOutputStream("archive.7z")) {
SevenZipEntrySettings settings = new SevenZipEntrySettings(new SevenZipLZMACompressionSettings());
settings.setSolid(true);
try (SevenZipArchive archive = new SevenZipArchive(settings)) {
archive.createEntries("C:\\Documents");
archive.save(sevenZipFile);
}
} catch (IOException ex) {
}
Provide SevenZipEntrySettings
for solid 7z archive on archive instantiation.
Returns: boolean - value indicating whether to concatenate entries and treat them as a single data block.
setCompressHeader(boolean value)
public final void setCompressHeader(boolean value)
Sets value indicating whether to compress archive header.
This setting is equivalent -mhc=on
switch of 7-Zip tool. Currently, it is incompatible with header encryption.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | a value indicating whether to compress archive header |
setSolid(boolean value)
public final void setSolid(boolean value)
Sets value indicating whether to concatenate entries and treat them as a single data block.
The following example shows how to compress a directory to solid 7z archive with LZMA2 compression without encryption.
try (FileOutputStream sevenZipFile = new FileOutputStream("archive.7z")) {
SevenZipEntrySettings settings = new SevenZipEntrySettings(new SevenZipLZMACompressionSettings());
settings.setSolid(true);
try (SevenZipArchive archive = new SevenZipArchive(settings)) {
archive.createEntries("C:\\Documents");
archive.save(sevenZipFile);
}
} catch (IOException ex) {
}
Provide SevenZipEntrySettings
for solid 7z archive on archive instantiation.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | value indicating whether to concatenate entries and treat them as a single data block. |