Question

I was trying to read a self-extracting zip (located here ftp://ftp.dnr.state.oh.us/OilGas/Download/Production/By_Year/2010Production.exe) using java code.

I tried three approaches, the one mentioned at How can I read from a Winzip self-extracting (exe) zip file in Java?

and the second one is to download the exe file and rename it to zip (thought the cheat might work)and then tried to read it...Both of them didn't work.

The final one using the 7-ZIP LZMA SDK, which is also not useful

Also, I looked at several other resources on Internet but nothing useful. Can some one please help me?

Was it helpful?

Solution

TrueZip works best in this case. (Atleast in my case)

The self extracting zip is of the following format code1 header1 file1 (while a normal zip is of the format header1 file1)...The code tells on how to extract the zip

Though the Truezip extracting utility complains about the extra bytes and throws an exception

Here is the code

 private boolean Extract(String src, String dst, String incPath) {


    TFile srcFile = new TFile(src, incPath);
    TFile dstFile = new TFile(dst);
    try {
        TFile.cp_rp(srcFile, dstFile, TArchiveDetector.NULL);
    } catch (IOException e) {
       return true;
    }

    return true;
}

You can call this method like Extract(new String("C:\2006Production.exe"), new String("c:\") , "");

You can download the Truezip source files package (jar) from here http://repo1.maven.org/maven2/de/schlichtherle/truezip/truezip-samples/7.5.5/truezip-samples-7.5.5-jar-with-dependencies.jar

You will need to import the classes in your code.

import de.schlichtherle.truezip.file.TArchiveDetector; import de.schlichtherle.truezip.file.TFile;

The file is extracted in the c drive...you can perform your own operation on your file. I hope this helps.

Thanks.

OTHER TIPS

Apache Commons Compress supports this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top