ArchiveLoadOptions
Inheritance: java.lang.Object
public class ArchiveLoadOptions
Alternativ med vilka ZIP-arkivet laddas från en komprimerad fil.
Konstruktörer
| Konstruktor | Beskrivning |
|---|---|
| ArchiveLoadOptions() |
Metoder
| Metod | Beskrivning |
|---|---|
| getDecryptionPassword() | Hämtar lösenordet för att avkryptera poster. |
| getEncoding() | Hämtar kodningen för posternas namn. |
| getEntryExtractionProgressed() | Hämtar en händelse som utlöses när några byte har extraherats. |
| getEntryListed() | Hämtar en händelse som utlöses när en post listas i innehållsförteckningen. |
| getForwardOnly() | Hämtar flaggan som indikerar att arkivet extraheras från en skrivskyddad ström. |
| getSkipChecksumVerification() | Hämtar ett värde som indikerar om kontrollsummeverifiering av ZIP-poster ska hoppas över och avvikelser ignoreras. |
| 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 avkryptera poster. |
| setEncoding(Charset value) | Ställer in kodningen för posternas namn. |
| setEntryExtractionProgressed(Event<ProgressCancelEventArgs> value) | Ställer in en händelse som utlöses när några byte har extraherats. |
| setEntryListed(Event<EntryEventArgs> value) | Ställer in en händelse som utlöses när en post listas i innehållsförteckningen. |
| setForwardOnly(boolean value) | Ställer in flaggan som indikerar att arkivet extraheras från en skrivskyddad ström. |
| setSkipChecksumVerification(boolean value) | Ställer in ett värde som indikerar om kontrollsummeverifiering av ZIP-poster ska hoppas över och avvikelser ignoreras. |
ArchiveLoadOptions()
public ArchiveLoadOptions()
getDecryptionPassword()
public final String getDecryptionPassword()
Hämtar lösenordet för att avkryptera poster.
Du kan ange avkrypteringslösenordet en gång vid arkivextraktion.
try (FileInputStream fs = new FileInputStream(“encrypted_archive.zip”)) { try (FileOutputStream extracted = new FileOutputStream(“extracted.bin”)) { ArchiveLoadOptions options = new ArchiveLoadOptions(); options.setDecryptionPassword(“p@s$”); try (Archive archive = new Archive(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); } archive.getEntries().get(0).extract(“first.bin”, “first_pass”); archive.getEntries().get(1).extract(“second.bin”, “second_pass”); } } } catch (IOException ex) { }
**Returns:**
java.lang.String - the password to decrypt entries
### getEncoding() {#getEncoding--}
public final Charset getEncoding()
Gets the encoding for entries' names.
Entry name composed using specified encoding regardless of zip file properties.
try (FileInputStream fs = new FileInputStream("archive.zip")) {
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEncoding(Charset.forName("MS932"));
try (Archive archive = new Archive(fs, options)) {
String name = archive.getEntries().get(0).getName();
}
} catch (IOException ex) {
}
```
**Returns:**
java.nio.charset.Charset - kodningen för posternas namn
### getEntryExtractionProgressed() {#getEntryExtractionProgressed--}
```
public final Event<ProgressCancelEventArgs> getEntryExtractionProgressed()
```
Hämtar en händelse som utlöses när några byte har extraherats.
Spåra framstegen för en postextraktion.
```
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEntryExtractionProgressed(new Event
Cancel an entry extraction after a certain time.
long startTime = System.nanoTime();
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEntryExtractionProgressed((s, e) -> {
if ((System.nanoTime() - startTime) / 1_000_000 > 1000)
e.setCancel(true);
});
try (Archive a = new Archive("big.zip", options)) {
a.getEntries().get(0).extract("first.bin");
}
```
Event avsändare är den [ArchiveEntry](../../com.aspose.zip/archiveentry) instans vars extraktion har fortskridit.
**Returns:**
[Event](../../com.aspose.zip/event) - an event that is raised when some bytes have been extracted
### getEntryListed() {#getEntryListed--}
```
public final Event<EntryEventArgs> getEntryListed()
```
Hämtar en händelse som utlöses när en post listas i innehållsförteckningen.
```
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEntryListed(new Event
**Returns:**
[Event](../../com.aspose.zip/event) - an event that is raised when an entry listed within table of content
### getForwardOnly() {#getForwardOnly--}
public final boolean getForwardOnly()
Gets the flag that indicating that archive is extracted from read-only stream.
**Returns:**
boolean - true, if archive's stream is rean-only, false elsewhere.
### getSkipChecksumVerification() {#getSkipChecksumVerification--}
public final boolean getSkipChecksumVerification()
Gets a value indicating whether checksum verification of ZIP entries be skipped and mismatch ignored. Default is false.
**Returns:**
boolean - a value indicating whether checksum verification of ZIP entries be skipped and mismatch ignored
### setCancellationFlag(CancellationFlag value) {#setCancellationFlag-com.aspose.zip.CancellationFlag-}
public void setCancellationFlag(CancellationFlag value)
Sets a cancellation flag used to cancel the extraction operation.
Cancel ZIP archive extraction after a certain time.
try (CancellationFlag cf = new CancellationFlag()) {
cf.cancelAfter(TimeUnit.SECONDS.toMillis(60));
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setCancellationFlag(cf);
try (Archive a = new Archive("big.zip", 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 avkryptera poster.
Du kan ange avkrypteringslösenordet en gång vid arkivextraktion.
```
try (FileInputStream fs = new FileInputStream(“encrypted_archive.zip”)) { try (FileOutputStream extracted = new FileOutputStream(“extracted.bin”)) { ArchiveLoadOptions options = new ArchiveLoadOptions(); options.setDecryptionPassword(“p@s$”); try (Archive archive = new Archive(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); } archive.getEntries().get(0).extract(“first.bin”, “first_pass”); archive.getEntries().get(1).extract(“second.bin”, “second_pass”); } } } catch (IOException ex) { }
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | java.lang.String | the password to decrypt entries |
### setEncoding(Charset value) {#setEncoding-java.nio.charset.Charset-}
public final void setEncoding(Charset value)
Sets the encoding for entries' names.
Entry name composed using specified encoding regardless of zip file properties.
try (FileInputStream fs = new FileInputStream("archive.zip")) {
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEncoding(Charset.forName("MS932"));
try (Archive archive = new Archive(fs, options)) {
String name = archive.getEntries().get(0).getName();
}
} catch (IOException ex) {
}
```
**Parameters:**
| Parameter | Typ | Beskrivning |
| --- | --- | --- |
| värde | java.nio.charset.Charset | kodningen för posternas namn |
### setEntryExtractionProgressed(Event<ProgressCancelEventArgs> value) {#setEntryExtractionProgressed-com.aspose.zip.Event-com.aspose.zip.ProgressCancelEventArgs--}
```
public final void setEntryExtractionProgressed(Event<ProgressCancelEventArgs> value)
```
Ställer in en händelse som utlöses när några byte har extraherats.
Spåra framstegen för en postextraktion.
```
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEntryExtractionProgressed(new Event
Cancel an entry extraction after a certain time.
long startTime = System.nanoTime();
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEntryExtractionProgressed((s, e) -> {
if ((System.nanoTime() - startTime) / 1_000_000 > 1000)
e.setCancel(true);
});
try (Archive a = new Archive("big.zip", options)) {
a.getEntries().get(0).extract("first.bin");
}
```
Event avsändare är den [ArchiveEntry](../../com.aspose.zip/archiveentry) instans vars extraktion har fortskridit.
**Parameters:**
| Parameter | Typ | Beskrivning |
| --- | --- | --- |
| värde | com.aspose.zip.Event<com.aspose.zip.ProgressCancelEventArgs> | en händelse som utlöses när några byte har extraherats |
### setEntryListed(Event<EntryEventArgs> value) {#setEntryListed-com.aspose.zip.Event-com.aspose.zip.EntryEventArgs--}
```
public final void setEntryListed(Event<EntryEventArgs> value)
```
Ställer in en händelse som utlöses när en post listas i innehållsförteckningen.
```
ArchiveLoadOptions options = new ArchiveLoadOptions();
options.setEntryListed(new Event
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | com.aspose.zip.Event<com.aspose.zip.EntryEventArgs> | an event that is raised when an entry listed within table of content |
### setForwardOnly(boolean value) {#setForwardOnly-boolean-}
public final void setForwardOnly(boolean value)
Sets the flag that indicating that archive is extracted from read-only stream.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | boolean | true, if archive's stream is rean-only, false elsewhere. |
### setSkipChecksumVerification(boolean value) {#setSkipChecksumVerification-boolean-}
public final void setSkipChecksumVerification(boolean value)
Sets a value indicating whether checksum verification of ZIP entries be skipped and mismatch ignored. Default is false.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | boolean | a value indicating whether checksum verification of ZIP entries be skipped and mismatch ignored |