DirectoryZipOutputStream extends ZipOutputStream { public DirectoryZipOutputStream(File destination, OutputStream out) { super(out); this.destination = destination; } DirectoryZipOutputStream(File destination, OutputStream out); @Override void putNextEntry(ZipEntry e); @Override void closeEntry(); @Override synchronized void write(byte[] b, int off, int len); @Override void flush(); @Override void write(int b); @Override void finish(); @Override void close(); @Override void setComment(String comment); @Override void write(byte[] b); @Override void setMethod(int method); @Override void setLevel(int level);  }
@Test public void testDirectoryZipOutputStream() throws IOException { File outputStreamFile = File.createTempFile("dirzip-output", null); FileOutputStream fileOutputStream = new FileOutputStream(outputStreamFile); DirectoryZipOutputStream directoryZipOutputStream = new DirectoryZipOutputStream(outputDirectory, fileOutputStream); createDirectoryContent(directoryZipOutputStream, "", 3, 3, 0, 4); directoryZipOutputStream.close(); fileOutputStream.close(); Assert.assertTrue("No write to the output stream should happen !", outputStreamFile.length() == 0); outputStreamFile.delete(); }