0

How do you extract an XZ file in Java? I have a 7z SFX file with an .exe extension, convert it into an XZ file but how do I finally extract its contents?

On Windows, I can easily do an right-click and let WinRAR do the extraction by selecting Extract here from the context menu.

Community
  • 1
  • 1
BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185

1 Answers1

0

try with this

try { 
    FileInputStream fin = new FileInputStream(path + "myFile.xz");
    BufferedInputStream in = new BufferedInputStream(fin);
    FileOutputStream out = new FileOutputStream(des + "myDecompressed");
    XZInputStream xzIn = new XZInputStream(in);
    final byte[] buffer = new byte[8192];
    int n = 0;
    while (-1 != (n = xzIn.read(buffer))) {
        out.write(buffer, 0, n);
    } 
    out.close();
    xzIn.close();
}
catch(Exception e) { 
    Log.e("Decompress", "unzip", e); 
suulisin
  • 1,414
  • 1
  • 10
  • 17