Package com.aspose.zip
Class Bzip2LoadOptions
- java.lang.Object
-
- com.aspose.zip.Bzip2LoadOptions
-
public class Bzip2LoadOptions extends Object
Options for loading
Bzip2Archive. Contains event raised on extraction.
-
-
Constructor Summary
Constructors Constructor Description Bzip2LoadOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Event<ProgressEventArgs>getExtractionProgressed()Gets an event that is raised when some bytes have been extracted.voidsetCancellationFlag(CancellationFlag value)Sets a cancellation flag used to cancel the extraction operation.voidsetExtractionProgressed(Event<ProgressEventArgs> value)Sets an event that is raised when some bytes have been extracted.
-
-
-
Method Detail
-
getExtractionProgressed
public Event<ProgressEventArgs> getExtractionProgressed()
Gets an event that is raised when some bytes have been extracted.
int[] percent = { 0 }; long originalFileLength = 10_000_000; Bzip2LoadOptions loadOptions = new Bzip2LoadOptions(); loadOptions.setExtractionProgressed((sender, args) -> { percent[0] = (int)((100 * (double)args.getProceededBytes()) / originalFileLength); });Event sender is the
Bzip2Archiveinstance which extraction is progressed. TheProgressEventArgs.getProceededBytes()(ProgressEventArgs.getProceededBytes()) is the number of bytes after extraction.- Returns:
- an event that is raised when some bytes have been extracted
-
setExtractionProgressed
public void setExtractionProgressed(Event<ProgressEventArgs> value)
Sets an event that is raised when some bytes have been extracted.
int[] percent = { 0 }; long originalFileLength = 10_000_000; Bzip2LoadOptions loadOptions = new Bzip2LoadOptions(); loadOptions.setExtractionProgressed((sender, args) -> { percent[0] = (int)((100 * (double)args.getProceededBytes()) / originalFileLength); });Event sender is the
Bzip2Archiveinstance which extraction is progressed. TheProgressEventArgs.getProceededBytes()(ProgressEventArgs.getProceededBytes()) is the number of bytes after extraction.- Parameters:
value- an event that is raised when some bytes have been extracted
-
setCancellationFlag
public void setCancellationFlag(CancellationFlag value)
Sets a cancellation flag used to cancel the extraction operation.
Cancel Bzip2 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)); Bzip2LoadOptions options = new Bzip2LoadOptions(); options.setCancellationFlag(cf); try (Bzip2Archive a = new Bzip2Archive("big.bz2", options)) { try { a.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.
-
-