Based on your response to my comment, it sounds like the parent directory for the file is not created before the record for the file in the archive is written.
It looks like you might need to modify the code associated with writing the file to a zip file in order to create parent directories if they do not already exist. You may also need to modify the code that creates the directories to check if the directory exists before it is created.
Try something like this:
while (files.hasMoreElements()) { ZipEntry entry = (ZipEntry) files.nextElement(); Log.d(TAG, "ZipEntry: "+entry); Log.d(TAG, "isDirectory: " + entry.isDirectory()); if (entry.isDirectory()) { File file = new File(path + entry.getName()); file.mkdir(); Log.d(TAG, "Create dir " + entry.getName()); } else { File f = new File(path + entry.getName()); f.getParentFile().mkdirs(); FileOutputStream fos = new FileOutputStream(f); InputStream is = zipFile.getInputStream(entry); byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = is.read(buffer)) != -1) { fos.write(buffer, 0, bytesRead); } fos.close(); Log.d(TAG, "Create File " + entry.getName()); } } Log.d(TAG, "Done extracting epub file");
For me, this gives the following result using a test epub (a mobile member from Google epub samples: https://code.google.com/p/epub-samples/downloads/list )
ZipEntry: mimetype isDirectory: false Create File mimetype ZipEntry: META-INF/ isDirectory: true Create dir META-INF/ ZipEntry: META-INF/container.xml isDirectory: false Create File META-INF/container.xml ZipEntry: OPS/ isDirectory: true Create dir OPS/ ZipEntry: OPS/chapter_001.xhtml isDirectory: false Create File OPS/chapter_001.xhtml ZipEntry: OPS/chapter_002.xhtml isDirectory: false Create File OPS/chapter_002.xhtml ZipEntry: OPS/chapter_003.xhtml isDirectory: false ... Create File OPS/toc-short.xhtml ZipEntry: OPS/toc.xhtml isDirectory: false Create File OPS/toc.xhtml Done extracting epub file
source share