fix for zip empty dir

This commit is contained in:
Loredana Crusoveanu 2018-09-22 21:09:23 +03:00
parent 1ee74058a2
commit 74a6d38d24
1 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,13 @@ public class ZipDirectory {
return;
}
if (fileToZip.isDirectory()) {
if (fileName.endsWith("/")) {
zipOut.putNextEntry(new ZipEntry(fileName));
zipOut.closeEntry();
} else {
zipOut.putNextEntry(new ZipEntry(fileName + "/"));
zipOut.closeEntry();
}
final File[] children = fileToZip.listFiles();
for (final File childFile : children) {
zipFile(childFile, fileName + "/" + childFile.getName(), zipOut);