Class Bzip2SaveOptions


  • public class Bzip2SaveOptions
    extends Object

    Options for saving a bzip2 archive.

    • Constructor Detail

      • Bzip2SaveOptions

        public Bzip2SaveOptions​(int blockSize)

        Initializes a new instance of the Bzip2SaveOptions class.

        
             try (FileOutputStream result = new FileOutputStream("archive.bz2")) {
                 try (Bzip2Archive archive = new Bzip2Archive()) {
                     archive.setSource("data.bin");
                     archive.save(result, new Bzip2SaveOptions(9));
                 }
             } catch (IOException ex) {
                 System.out.println(ex);
             }
         
        Parameters:
        blockSize - Block size in hundreds of kilobytes.
        Throws:
        com.aspose.ms.System.ArgumentOutOfRangeException - Block size is not in valid range.
      • Bzip2SaveOptions

        public Bzip2SaveOptions()

        Initializes a new instance of the Bzip2SaveOptions class with default block size, equals to 9 hundred of kilobytes.

        
             try (FileOutputStream result = new FileOutputStream("archive.bz2")) {
                 try (Bzip2Archive archive = new Bzip2Archive()) {
                     archive.setSource("data.bin");
                     archive.save(result, new Bzip2SaveOptions());
                 }
             } catch (IOException ex) {
                 System.out.println(ex);
             }
         
    • Method Detail

      • getCompressionProgressed

        public Event<ProgressEventArgs> getCompressionProgressed()

        Gets an event that is raised when a portion of raw stream compressed.

        
             File source = new File("huge.bin");
             Bzip2SaveOptions settings = new Bzip2SaveOptions();
             settings.setCompressionProgressed((sender, args) -> {
                 int percent = (int)((100 * args.getProceededBytes()) / source.length());
             });
         

        This event won't be raised when compressing in multithreaded mode.

        Returns:
        an event that is raised when a portion of raw stream compressed
      • setCompressionProgressed

        public void setCompressionProgressed​(Event<ProgressEventArgs> value)

        Sets an event that is raised when a portion of raw stream compressed.

        
             File source = new File("huge.bin");
             Bzip2SaveOptions settings = new Bzip2SaveOptions();
             settings.setCompressionProgressed((sender, args) -> {
                 int percent = (int)((100 * args.getProceededBytes()) / source.length());
             });
         

        This event won't be raised when compressing in multithreaded mode.

        Parameters:
        value - an event that is raised when a portion of raw stream compressed
      • getBlockSize

        public final int getBlockSize()

        Block size in hundreds of kilobytes.

        Returns:
        block size in hundreds of kilobytes
      • getCompressionThreads

        public final int getCompressionThreads()

        Gets compression thread count. If the value is greater than 1, multithreading compression will be used.

        Returns:
        compression thread count.
      • setCompressionThreads

        public final void setCompressionThreads​(int value)

        Sets compression thread count. If the value is greater than 1, multithreading compression will be used.

        Parameters:
        value - compression thread count.