tinkerwell / jodd

Automatically exported from code.google.com/p/jodd
0 stars 0 forks source link

ZipUtil.addToZip() Method Incorrect. #26

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ZipUtil.addToZip() Method Incorrect.it no add Any subdirectory into zip file.

souce code:

//-----------------------------------------------------------
import java.io.File;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

import jodd.io.StreamUtil;
import jodd.io.ZipUtil;

public class TestZip {
  public static void main(String[] args) throws Exception {
    String zipFilename = "testzip.zip";
    ZipOutputStream zos = null;
    try {
      zos = ZipUtil.createZip(zipFilename);

      File[] childs = (new File("./src")).listFiles();
      if (childs != null) {
        for (File child : childs) {
          ZipUtil.addToZip(zos, child);
        }
      }
    } finally {
      StreamUtil.close(zos);
    }

    ZipFile zipfile = new ZipFile(zipFilename);
    try {
      for (Enumeration<? extends ZipEntry> entries = zipfile.entries(); entries.hasMoreElements();) {
        ZipEntry enty = entries.nextElement();
        String zipEntryName = enty.getName();
        if (enty.isDirectory()) {
          System.out.println(zipEntryName);
        }
      }
    } finally {
      zipfile.close();
    }

  }
}

Original issue reported on code.google.com by wjw465...@gmail.com on 18 Sep 2012 at 7:27

GoogleCodeExporter commented 9 years ago
thank you for letting us know! Please allow us some more time to fix this, as 
we are in the middle of moving to gitHub and mavenizing the project! thank you 
for understanding!

Original comment by i...@jodd.org on 18 Sep 2012 at 8:47

GoogleCodeExporter commented 9 years ago

Original comment by i...@jodd.org on 27 Sep 2012 at 2:10

GoogleCodeExporter commented 9 years ago
And we thought this is how it should be:)))

Thank you again, we added folder entries for non-empty folders.

Commit# eb98b73ed3844e2a57dae9a5269ab7833bff5f6a

p.s. sorry for long wait

Original comment by i...@jodd.org on 27 Sep 2012 at 7:36