Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created April 16, 2025 19:53
Show Gist options
  • Save aspose-com-gists/2753ffd25ea21e1b6e229221dc6596c6 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/2753ffd25ea21e1b6e229221dc6596c6 to your computer and use it in GitHub Desktop.
Open XAR Files
public class main {
public static void main(String[] args) throws FileNotFoundException, java.io.IOException {
// Set the path for the working directories.
String sourceFile = "/files/sample.xar";
String outDir = "/Desktop/";
// Open a file input stream to read the .xar file located at the given path.
try (FileInputStream fis = new FileInputStream(sourceFile)) {
// Initialize an instance of the XarArchive class with the input stream.
try (XarArchive archive = new XarArchive(fis)) {
// Extract all the files in the archive to the directory provided by calling the extractToDirectory method.
archive.extractToDirectory(outDir + "DecompressXar_out");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment