0

I have a .taz file that I need to uncompress and get content from. I've done so far some research and found a commercial library offering this feature (Here is the link)

Is there any free/open source method I can use to extract content from the .taz file using Java?

javadev
  • 1,639
  • 2
  • 17
  • 35

2 Answers2

1

you can try apache compress, I used it some time before (for another compression), but it can handle both zip and tar (not completely sure what is TAZ)

sodik
  • 4,675
  • 2
  • 29
  • 47
0

I would like to recommend you use console tool for compressing/uncompressing data if its acceptable. Almost all java lib have a lot of bad sides : lower perfomance, using much more memory and more CPU. I had a problem with uncompressing few big files (to reproduce, file should be more than 2 GB)

I use next code to uncompress list of compressed files.

 public int extractFiles(final String zipFile, final File folder, final String[] neededFiles) throws IOException {

    try {
        final String filesString = StringUtils.join(neededFiles, " ");
        final String command = "/bin/tar -xvf " + zipFile + " " + filesString;
        logger.info("Start unzipping: {}    into the folder {}", command, folder.getPath());
        final Runtime r = Runtime.getRuntime();
        final Process p = r.exec(command, null, folder);
        logger.debug("process started");
        final int returnCode = p.waitFor();

        if (logger.isWarnEnabled()) {
            final BufferedReader is = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = is.readLine()) != null) {
                logger.warn(line);
            }
            final BufferedReader is2 = new BufferedReader(new InputStreamReader(p.getErrorStream()));
            while ((line = is2.readLine()) != null) {
                logger.warn(line);
            }
        }

        logger.info("File {} unzipped [code = {}]", zipFile, returnCode);
        return returnCode;
    } catch (final InterruptedException e) {
        logger.error("Error", e);
        return -1;
    }

}

This option much faster and don't require a lot of memory. Sure, this method platform depended, but works on all(almost all) Unix systems.

P.S. actually most code its just logging :).

iMysak
  • 2,170
  • 1
  • 22
  • 35