XarLoadOptions

Inheritance: java.lang.Object

public class XarLoadOptions

Options with which XAR archive is loaded from a compressed file.

Constructors

ConstructorDescription
XarLoadOptions()

Methods

MethodDescription
getEntryExtractionProgressed()Gets an event that is raised when some bytes have been extracted.
setCancellationFlag(CancellationFlag value)Sets a cancellation flag used to cancel the extraction operation.
setEntryExtractionProgressed(Event<ProgressEventArgs> value)Sets an event that is raised when some bytes have been extracted.

XarLoadOptions()

public XarLoadOptions()

getEntryExtractionProgressed()

public final Event<ProgressEventArgs> getEntryExtractionProgressed()

Gets an event that is raised when some bytes have been extracted.


     XarLoadOptions loadOptions = new XarLoadOptions();
     loadOptions.setEntryExtractionProgressed((sender, args) -> {
         int percent = (int)((100 * args.getProceededBytes()) / ((XarFileEntry)sender).getLength());
     });
     XarArchive archive = new XarArchive("archive.xar", loadOptions);
 

Event sender is the XarFileEntry instance which extraction is progressed.

Returns: Event - an event that is raised when some bytes have been extracted

setCancellationFlag(CancellationFlag value)

public void setCancellationFlag(CancellationFlag value)

Sets a cancellation flag used to cancel the extraction operation.

Cancel XAR archive extraction after a certain time.


     try (CancellationFlag cf = new CancellationFlag()) {
         cf.cancelAfter(TimeUnit.SECONDS.toMillis(60));
         XarLoadOptions options = new XarLoadOptions();
         options.setCancellationFlag(cf);
         try (XarArchive a = new XarArchive("big.xar", options)) {
             try {
                 ((XarFileEntry) a.getEntries().get(0)).extract("data.bin");
             } catch (OperationCanceledException e) {
                 System.out.println("Extraction was cancelled after 60 seconds");
             }
         }
     }
 

Cancellation mostly results in some data not being extracted.

Parameters:

ParameterTypeDescription
valueCancellationFlaga cancellation flag used to cancel the extraction operation.

setEntryExtractionProgressed(Event<ProgressEventArgs> value)

public final void setEntryExtractionProgressed(Event<ProgressEventArgs> value)

Sets an event that is raised when some bytes have been extracted.


     XarLoadOptions loadOptions = new XarLoadOptions();
     loadOptions.setEntryExtractionProgressed((sender, args) -> {
         int percent = (int)((100 * args.getProceededBytes()) / ((XarFileEntry)sender).getLength());
     });
     XarArchive archive = new XarArchive("archive.xar", loadOptions);
 

Event sender is the XarFileEntry instance which extraction is progressed.

Parameters:

ParameterTypeDescription
valuecom.aspose.zip.Event<com.aspose.zip.ProgressEventArgs>an event that is raised when some bytes have been extracted