Package com.aspose.zip
Class SevenZipLoadOptions
- java.lang.Object
-
- com.aspose.zip.SevenZipLoadOptions
-
public class SevenZipLoadOptions extends Object
Options with which
SevenZipArchiveis loaded from a compressed file.
-
-
Constructor Summary
Constructors Constructor Description SevenZipLoadOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDecryptionPassword()Gets the password to decrypt entries and entry names.voidsetCancellationFlag(CancellationFlag value)Sets a cancellation flag used to cancel the extraction operation.voidsetDecryptionPassword(String value)Sets the password to decrypt entries and entry names.
-
-
-
Method Detail
-
getDecryptionPassword
public final String getDecryptionPassword()
Gets the password to decrypt entries and entry names.
You can provide decryption password once on archive extraction.
try (FileInputStream fs = new FileInputStream("encrypted_archive.7z"); FileOutputStream extracted = new FileOutputStream("extracted.bin")) { SevenZipLoadOptions options = new SevenZipLoadOptions(); options.setDecryptionPassword("p@s$"); try (SevenZipArchive archive = new SevenZipArchive(fs, options); InputStream decompressed = archive.getEntries().get(0).open()) { byte[] b = new byte[8192]; int bytesRead; while (0 < (bytesRead = decompressed.read(b, 0, b.length))) { extracted.write(b, 0, bytesRead); } } } catch (IOException ex) { }- Returns:
- the password to decrypt entries and entry names.
- See Also:
SevenZipArchiveEntry.open(String)
-
setDecryptionPassword
public final void setDecryptionPassword(String value)
Sets the password to decrypt entries and entry names.
You can provide decryption password once on archive extraction.
try (FileInputStream fs = new FileInputStream("encrypted_archive.7z"); FileOutputStream extracted = new FileOutputStream("extracted.bin")) { SevenZipLoadOptions options = new SevenZipLoadOptions(); options.setDecryptionPassword("p@s$"); try (SevenZipArchive archive = new SevenZipArchive(fs, options); InputStream decompressed = archive.getEntries().get(0).open()) { byte[] b = new byte[8192]; int bytesRead; while (0 < (bytesRead = decompressed.read(b, 0, b.length))) { extracted.write(b, 0, bytesRead); } } } catch (IOException ex) { }- Parameters:
value- the password to decrypt entries and entry names.- See Also:
SevenZipArchiveEntry.open(String)
-
setCancellationFlag
public void setCancellationFlag(CancellationFlag value)
Sets a cancellation flag used to cancel the extraction operation.
Cancel 7Z archive extraction after a certain time.
Cancellation mostly results in some data not being extracted.try (CancellationFlag cf = new CancellationFlag()) { cf.cancelAfter(TimeUnit.SECONDS.toMillis(60)); SevenZipLoadOptions options = new SevenZipLoadOptions(); options.setCancellationFlag(cf); try (SevenZipArchive a = new SevenZipArchive("big.7z", options)) { try { a.getEntries().get(0).extract("data.bin"); } catch (OperationCanceledException e) { System.out.println("Extraction was cancelled after 60 seconds"); } } }- Parameters:
value- a cancellation flag used to cancel the extraction operation.
-
-