跳至正文
首页 » 博客 » Convert ZIP to 7Z in Java using a 7Z SDK

Convert ZIP to 7Z in Java using a 7Z SDK

Introduction

  • We will briefly go through how we can leverage Aspose.ZIP for Java to convert ZIP to 7Z in Java programmatically.

Java 7Z SDK Installation

  • This section takes you to the installation of this Java 7Z SDK.

Steps to Create 7Z File Programmatically

  • We will walk through the steps to automate the process of developing a 7Z file archiver.

Convert ZIP to 7Z in Java – Code Sample

  • Finally, we will write a complete code snippet using the classes and methods exposed by Aspose.ZIP for Java.

#

In our recent blog post, we implemented the functionality of converting RAR to ZIP in Java programmatically. However, in this guide, we will see how to convert ZIP to 7Z in Java. Aspose.ZIP for Java is a powerful library that provides a robust solution to convert a ZIP archive to a 7Z file extension. Further, you will find this library a go-to solution for building a 7Z file archiver for your business application.

Java 7Z SDK Installation#

The installation process is not more than downloading this JAR file or using the following Maven configurations:

 <repositories>
     <repository>
         <id>snapshots</id>
         <name>repo</name>
         <url>http://repository.aspose.com/repo/</url>
     </repository>
</repositories>
 <dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-zip</artifactId>
        <version>24.5</version>
    </dependency>
</dependencies>

Steps to Create 7Z File Programmatically#

The following steps are to develop a 7Z file archiver programmatically:

  • Initialize an instance of the Archive class with a source ZIP file.
  • Create an object of the SevenZipLZMA2CompressionSettings class.
  • Instantiate an instance of the SevenZipEntrySettings class with the object of the SevenZipLZMA2CompressionSettings class.
  • Create an object of the SevenZipArchive class and pass an instance of the SevenZipEntrySettings class.
  • Loop through the entries returned by the getEntries method.
  • Invoke the save method to save the 7Z file on the disk.

Convert ZIP to 7Z in Java – Code Sample#

Enough claims, let’s write some code now. You can implement how to convert ZIP to 7Z in Java using the code sample given below:

Output:

ZIP File Converter – Get a Free License#

You can get a free temporary license to try this Java 7Z SDK without evaluation limitations.

Summing up#

That’s it. You have seen the output above in this guide. Aspose.ZIP for Java is truly a game changer 7Z SDK for Java programmers to convert ZIP to 7Z in Java programmatically. Further, you can visit the documentation, API references and the Getting Started guide to explore more. Finally, aspose.com is writing new blog posts. So, keep visiting us for the regular updates.

Ask a question#

You can let us know about your questions or queries on our forum.

See Also#

  • Convert RAR to ZIP in Java – Java RAR API
  • Unzip Files Online – Free ZIP Extractor