2009/9/22 Arne v.Irmer <[email protected]>:
> Hi,
> with the command line program "zip" I can create a zip-File with annotated
> folders inside. I try to generate such a zip-File with the
> org.apache.tools.zip classes coming with ant.jar.
>
> Here is my small example program:
>
> package org.example.zip;
>
> import java.io.BufferedOutputStream;
> import java.io.FileOutputStream;
>
> import org.apache.tools.zip.ZipEntry;
> import org.apache.tools.zip.ZipOutputStream;
>
> public class ZipTest {
> public static void main (String argv[]) {
> try {
> FileOutputStream dest = new
> FileOutputStream("/tmp/checkFolder.zip");
> ZipOutputStream out = new ZipOutputStream(new
> BufferedOutputStream(dest));
>
> ZipEntry folderEntry = new ZipEntry("TestFolder");
In the souce code for ZipEntry I see
public boolean isDirectory() {
return getName().endsWith("/");
}
so I expect that should be new ZipEntry("TestFolder/")...
"TestFolder" is a perfectly valid name for a file - extensions aren't
mandatory, especially on non-windows systems. The fact you don't call
out.write() for folderEntry explains why it then has a length of 0,
but asides from that it looks to me that you're creating two files,
one of which happens to be in a folder with the same name as the first
one (hence the errors you get when unzipping).
I'm curious what exactly this has to do with Ant, though?
Andy
--
http://pseudoq.sourceforge.net/ open source java sudoku application
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]