Created
June 17, 2025 21:36
-
-
Save aspose-com-gists/d643131c1e7effea706751d75dd0aca4 to your computer and use it in GitHub Desktop.
Decompress Xar Files using Java SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import com.aspose.zip.XarArchive; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
public class main { | |
public static void main(String[] args) { | |
// Define input and output directory paths. | |
String dataDir = "files"; | |
String outDir = "output"; | |
// Open a FileInputStream to read the XAR archive from the specified path. | |
try (FileInputStream fis = new FileInputStream(dataDir + "sample.xar")) { | |
// Load the XAR archive from the input stream by creating an instance of the XarArchive class. | |
try (XarArchive archive = new XarArchive(fis)) { | |
// Extract all files in the archive to the specified output directory by calling the extractToDirectory method. | |
archive.extractToDirectory(outDir + ""); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
//ExEnd: DecompressXarArchive | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment