How to get the uncompressed size of a xz archive from Java?

  • trfd

    trfd - 2014-10-21

    Hello and thank you very much for providing this great tool! I am trying to integrate XZ Utils into a Java program of mine which sometimes needs to decompress large files. Since I don't want the GUI to just freeze, I would like to know what will be the final size of on the disk and count how much have already been written in order to show a progress windows. The problem is that I can't get the final uncompressed size of the files. Is there any way to get this information?

  • Lasse Collin

    Lasse Collin - 2014-10-24

    If you use XZ for Java, open the .xz file using SeekableXZInputStream and use its length() method. You can then decompress the file with the same input stream too.

    If you call XZ Utils' xz tool from your Java program, you can get the uncompressed size by parsing the output of xz --robot --list. Uncompressed size is the fifth column on the "file" line. Using XZ for Java is typically a better idea than calling xz from a Java program.

  • trfd

    trfd - 2014-11-11

    This helped. Thanks a lot! I use XZ for Java. Many thanks!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks