Bzip2SaveOptions
Contents
[
Hide
]Inheritance: java.lang.Object
public class Bzip2SaveOptions
Options for saving a bzip2 archive.
Constructors
| Constructor | Description |
|---|---|
| Bzip2SaveOptions(int blockSize) | Initializes a new instance of the Bzip2SaveOptions class. |
| Bzip2SaveOptions() | Initializes a new instance of the Bzip2SaveOptions class with default block size, equals to 9 hundred of kilobytes. |
Methods
| Method | Description |
|---|---|
| getBlockSize() | Block size in hundreds of kilobytes. |
| getCompressionProgressed() | Gets an event that is raised when a portion of raw stream compressed. |
| getCompressionThreads() | Gets compression thread count. |
| setCompressionProgressed(Event<ProgressEventArgs> value) | Sets an event that is raised when a portion of raw stream compressed. |
| setCompressionThreads(int value) | Sets compression thread count. |
Bzip2SaveOptions(int blockSize)
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:**
| Parameter | Type | Description |
| --- | --- | --- |
| blockSize | int | Block size in hundreds of kilobytes. |
### Bzip2SaveOptions() {#Bzip2SaveOptions--}
public Bzip2SaveOptions()
Initializes a new instance of the [Bzip2SaveOptions](../../com.aspose.zip/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);
}
```
### getBlockSize() {#getBlockSize--}
```
public final int getBlockSize()
```
Block size in hundreds of kilobytes.
**Returns:**
int - block size in hundreds of kilobytes
### getCompressionProgressed() {#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:**
[Event](../../com.aspose.zip/event) - an event that is raised when a portion of raw stream compressed
### getCompressionThreads() {#getCompressionThreads--}
public final int getCompressionThreads()
Gets compression thread count. If the value is greater than 1, multithreading compression will be used.
**Returns:**
int - compression thread count.
### setCompressionProgressed(Event<ProgressEventArgs> value) {#setCompressionProgressed-com.aspose.zip.Event-com.aspose.zip.ProgressEventArgs--}
public void setCompressionProgressed(Event
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:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | com.aspose.zip.Event<com.aspose.zip.ProgressEventArgs> | an event that is raised when a portion of raw stream compressed |
### setCompressionThreads(int value) {#setCompressionThreads-int-}
```
public final void setCompressionThreads(int value)
```
Sets compression thread count. If the value is greater than 1, multithreading compression will be used.
**Parameters:**
| Parameter | Type | Description |
| --- | --- | --- |
| value | int | compression thread count. |