1

In an application we use the zip4j library to decompress zip files.

File toBeExtractedFile = new File("valid/path/to/File");
ZipFile zipFile = new ZipFile(toBeExtractedFile);
zipFile.setFileNameCharset(StandardCharsets.UTF_8.name);
zipFile.extractAll("valid/path")

With .zip files this code works perfectly fine. But when done with a .tar file, this wil throw a new ZipException("zip headers not found. probably not a zip file"); Can the zip4j library extract TAR files when given additional info or parameters or do i have to resort to using something else like a TarArchiveInputstream?

Stephan Hogenboom
  • 1,543
  • 2
  • 17
  • 29

1 Answers1

1

No, ZIP and TAR are two different archive formats. You can use Apache Commons Compress which supports TAR format.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111