commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ChadDavis <chadmichaelda...@gmail.com>
Subject zip example on wiki
Date Fri, 04 Dec 2009 17:13:36 GMT
Here's the zip example from the wiki:

		final OutputStream out = new FileOutputStream("myfile.zip");
		ArchiveOutputStream os = new
ArchiveStreamFactory().createArchiveOutputStream("zip", out);

		os.putArchiveEntry(new ZipArchiveEntry("testdata/test1.xml"));
		IOUtils.copy(new FileInputStream(file1), os);
		os.closeArchiveEntry();

		os.putArchiveEntry(new ZipArchiveEntry("testdata/test2.xml"));
		IOUtils.copy(new FileInputStream(file2), os);
		os.closeArchiveEntry();
		
		out.finish();
		os.close();


Questions:

1) the second to last line, out.finish() -- there's no finish method
on an OutputStream.  Is this supposed to be calling the finish method
on the "os" stream, the ArchiveOutputStream I mean.

2) If so ( referring to question #1), why is this necessary?  The docs
make it sound as if finish() is only for when you want to stop and add
some more later . . .

3) Why is the output stream decalred as "final"?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message