java - Extracting SFX 7-Zip -
i want extract 2 specific files .zip
file. tried following library:
zipfile zipfile = new zipfile("myzip.zip");
result:
exception in thread "main" java.util.zip.zipexception: error in opening zip file
i tried:
public void extract(string targetfilename) throws ioexception { outputstream outputstream = new fileoutputstream("targetfile.foo"); fileinputstream fileinputstream = new fileinputstream("myzip.zip"); zipinputstream zipinputstream = new zipinputstream(new bufferedinputstream(fileinputstream)); zipentry zipentry; while ((zipentry = zipinputstream.getnextentry()) != null) { if (zipentry.getname().equals("targetfile.foo")) { byte[] buffer = new byte[8192]; int length; while ((length = zipinputstream.read(buffer)) != -1) { outputstream.write(buffer, 0, length); } outputstream.close(); break; } } }
result:
no exception, empty targetfile.foo
file.
note .zip
file of type sfx 7-zip
, had .exe
extensions may reason failure.
Comments
Post a Comment