Working with Lzip Archives in Java
Contents
[
Hide
Show
]Overview
Lzip archive is common in Linux. It uses LZMA algorithm. Aspose.ZIP for Java API lets work with creating and managing Lzip archives in your applications without the need of any other 3rd party applications. Aspose.ZIP API provides LzipArchive class to work with such archives. This class provides basic methods to perform operations on archives.
Compress A File
The following code example shows how to compress a file using LzipArchive instance.
1try (LzipArchive archive = new LzipArchive()) {
2 archive.setSource("data.bin");
3 archive.save("data.bin.lz");
4}
Extract Lzip Archive
The following simple code example shows how to open a Lzip archive.
1try (FileInputStream sourceLzipFile = new FileInputStream("data.bin.lz")) {
2 try (FileOutputStream extractedFile = new FileOutputStream("data.bin")) {
3 try (LzipArchive archive = new LzipArchive(sourceLzipFile)) {
4 archive.extract(extractedFile);
5 }
6 }
7} catch (IOException ex) {
8}