Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created June 17, 2025 21:36
Show Gist options
  • Save aspose-com-gists/d643131c1e7effea706751d75dd0aca4 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/d643131c1e7effea706751d75dd0aca4 to your computer and use it in GitHub Desktop.
Decompress Xar Files using Java SDK
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