RarArchiveLoadOptions
Inheritance: java.lang.Object
public class RarArchiveLoadOptions
Alternativ med vilka RarArchive laddas från en komprimerad fil.
Konstruktörer
| Konstruktor | Beskrivning |
|---|---|
| RarArchiveLoadOptions() |
Metoder
| Metod | Beskrivning |
|---|---|
| getDecryptionPassword() | Hämtar lösenordet för att dekryptera poster och postnamn. |
| getDictionaryStorageMode() | Hämtar hur RAR-dekomprimeringsordlistan lagras. |
| getTemporaryDirectory() | Hämtar katalogen som används för temporära ordboksfiler. |
| setCancellationFlag(CancellationFlag value) | Ställer in en avbrytningsflagga som används för att avbryta extraheringsoperationen. |
| setDecryptionPassword(String value) | Ställer in lösenordet för att dekryptera poster och postnamn. |
| setDictionaryStorageMode(RarDictionaryStorageMode value) | Ställer in hur RAR-dekomprimeringsordlistan lagras. |
| setTemporaryDirectory(String value) | Ställer in katalogen som används för temporära ordboksfiler. |
RarArchiveLoadOptions()
public RarArchiveLoadOptions()
getDecryptionPassword()
public final String getDecryptionPassword()
Hämtar lösenordet för att dekryptera poster och postnamn.
Du kan ange avkrypteringslösenordet en gång vid arkivextraktion.
try (FileInputStream fs = new FileInputStream(“encrypted_archive.rar”)) { try (FileOutputStream extracted = new FileOutputStream(“extracted.bin”)) { RarArchiveLoadOptions options = new RarArchiveLoadOptions(); options.setDecryptionPassword(“p@s$”); try (RarArchive archive = new RarArchive(fs, options)) { try (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:**
java.lang.String - the password to decrypt entries and entry names.
### getDictionaryStorageMode() {#getDictionaryStorageMode--}
public final RarDictionaryStorageMode getDictionaryStorageMode()
Gets how the RAR decompression dictionary is stored.
**Returns:**
[RarDictionaryStorageMode](../../com.aspose.zip/rardictionarystoragemode) - the dictionary storage mode
### getTemporaryDirectory() {#getTemporaryDirectory--}
public final String getTemporaryDirectory()
Gets the directory used for temporary dictionary files.
**Returns:**
java.lang.String - the temporary directory; the system temporary directory is used by default
### setCancellationFlag(CancellationFlag value) {#setCancellationFlag-com.aspose.zip.CancellationFlag-}
public void setCancellationFlag(CancellationFlag value)
Sets a cancellation flag used to cancel the extraction operation.
Cancel RAR archive extraction after a certain time.
try (CancellationFlag cf = new CancellationFlag()) {
cf.cancelAfter(TimeUnit.SECONDS.toMillis(60));
RarArchiveLoadOptions options = new RarArchiveLoadOptions();
options.setCancellationFlag(cf);
try (RarArchive a = new RarArchive("big.rar", options)) {
try {
a.getEntries().get(0).extract("data.bin");
} catch (OperationCanceledException e) {
System.out.println("Extraction was cancelled after 60 seconds");
}
}
}
```
Avbrytning resulterar oftast i att vissa data inte extraheras.
**Parameters:**
| Parameter | Typ | Beskrivning |
| --- | --- | --- |
| value | [CancellationFlag](../../com.aspose.zip/cancellationflag) | en avbrytande flagga som används för att avbryta extraktionsoperationen. |
### setDecryptionPassword(String value) {#setDecryptionPassword-java.lang.String-}
```
public final void setDecryptionPassword(String value)
```
Ställer in lösenordet för att dekryptera poster och postnamn.
Du kan ange avkrypteringslösenordet en gång vid arkivextraktion.
```
try (FileInputStream fs = new FileInputStream(“encrypted_archive.rar”)) { try (FileOutputStream extracted = new FileOutputStream(“extracted.bin”)) { RarArchiveLoadOptions options = new RarArchiveLoadOptions(); options.setDecryptionPassword(“p@s$”); try (RarArchive archive = new RarArchive(fs, options)) { try (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:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | java.lang.String | the password to decrypt entries and entry names. |
### setDictionaryStorageMode(RarDictionaryStorageMode value) {#setDictionaryStorageMode-com.aspose.zip.RarDictionaryStorageMode-}
public final void setDictionaryStorageMode(RarDictionaryStorageMode value)
Sets how the RAR decompression dictionary is stored.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | [RarDictionaryStorageMode](../../com.aspose.zip/rardictionarystoragemode) | the dictionary storage mode |
### setTemporaryDirectory(String value) {#setTemporaryDirectory-java.lang.String-}
public final void setTemporaryDirectory(String value)
Sets the directory used for temporary dictionary files. A null or empty value selects the system temporary directory.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | java.lang.String | the temporary directory |