I meet a problem when using zip4j library to generate zipfile in android, here's the code :
try {
ZipFile zipFile = new ZipFile(dest);
zipFile.setFileNameCharset("GBK");
if (srcFile.isDirectory()) {
zipFile.addFolder(srcFile, parameters);
} else {
zipFile.addFile(srcFile, parameters);
}
} catch (Exception e) {
e.printStackTrace();
}
and I got the Exception msg:
net.lingala.zip4j.exception.ZipException: Probably not a zip file or a corrupted zip file
at net.lingala.zip4j.core.HeaderReader.readEndOfCentralDirectoryRecord(HeaderReader.java:179)
at net.lingala.zip4j.core.HeaderReader.readAllHeaders(HeaderReader.java:78)
at net.lingala.zip4j.core.ZipFile.readZipInfo(ZipFile.java:425)
at net.lingala.zip4j.core.ZipFile.checkZipModel(ZipFile.java:935)
at net.lingala.zip4j.core.ZipFile.addFiles(ZipFile.java:263)
at net.lingala.zip4j.core.ZipFile.addFile(ZipFile.java:250)
Caused by: java.io.IOException: Negative seek offset
at java.io.RandomAccessFile.seek(RandomAccessFile.java:555)
at net.lingala.zip4j.core.HeaderReader.readEndOfCentralDirectoryRecord(HeaderReader.java:117)
This code works perfect in Eclipse for local files, but does not work well in Android, I'm pretty sure the destination .zip path is correct, and the zip4j library version is 1.3.2.
could anyone give me any suggestion?