Parallel bzip2 compression

Contents
[ Hide Show ]

Using several CPU cores

Bzip2 divides data into blocks and compresses them independently. Aspose.ZIP API allows to do it in parallel. The only thing you need to turn it on is set setCompressionThreads to more then one.

In the sample all CPU cores are used.

1try (Bzip2Archive archive = new Bzip2Archive()) {
2    archive.setSource("data.bin");
3    Bzip2SaveOptions options = new Bzip2SaveOptions();
4    options.setCompressionThreads(Runtime.getRuntime().availableProcessors());
5    archive.save("result.bz2", options);
6}

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.