Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.java > #12862
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Christoph Schneegans <Christoph@Schneegans.de> |
| Newsgroups | de.comp.lang.java |
| Subject | ZipOutputStream korrekt verwenden |
| Date | Tue, 1 Dec 2015 23:10:19 +0100 |
| Lines | 48 |
| Message-ID | <dc6k6cFmndeU1@mid.individual.net> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net UGLgZuYbywfzedy8loir2wR00c1bjPZu7KDtKHsXBkMdByFA== |
| Cancel-Lock | sha1:FY7eoe92/AHFA/8jKDynYkEdEOM= |
| X-Mozilla-News-Host | news://news.individual.de:119 |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
| Xref | csiph.com de.comp.lang.java:12862 |
Show key headers only | View raw
Hallo allerseits!
Ich möchte mit java.util.zip.ZipOutputStream ein .zip-Archiv erstellen.
Leider ist die Dokumentation der Klasse recht dürftig. Mir ist nun
insbesondere unklar, wie Unterverzeichnisse im Archiv korrekt behandelt
werden müssen.
Ich gehe davon aus, daß ich etwa mit
ZipOutputStream zip = ...
ZipEntry entry = new ZipEntry("dir/");
zip.putNextEntry(entry);
zip.closeEntry();
einen Unterverzeichnis-Eintrag und mit
ZipOutputStream zip = ...
ZipEntry entry = new ZipEntry("dir/file.txt");
zip.putNextEntry(entry);
zip.write("abcdef".getBytes());
zip.closeEntry();
einen Datei-Eintrag erstelle.
Gibt es denn überhaupt eine technische Notwendigkeit,
Unterverzeichnis-Einträge explizit zu erstellen? ZipOutputStream hindert
mich ja nicht daran, _nur_
ZipEntry entry = new ZipEntry("dir/file.txt");
aufzurufen. Die resultierende .zip-Datei hat dann nur einen Eintrag, und
dennoch kann man sie etwa in 7-Zip tadellos öffnen und dort in ein
Verzeichnis "dir" wechseln.
Spielt die Reihenfolge ansonsten eine Rolle? Wäre etwa
ZipEntry entry = new ZipEntry("dir/foo.txt");
...
ZipEntry entry = new ZipEntry("dir/");
...
ZipEntry entry = new ZipEntry("dir/bar.txt");
...
fehlerhaft?
--
<http://schneegans.de/lv/> · Validator für BCP 47
Back to de.comp.lang.java | Previous | Next — Next in thread | Find similar
ZipOutputStream korrekt verwenden Christoph Schneegans <Christoph@Schneegans.de> - 2015-12-01 23:10 +0100 Re: ZipOutputStream korrekt verwenden Claus Reibenstein <4spamersonly@kabelmail.de> - 2015-12-02 21:00 +0100 Re: ZipOutputStream korrekt verwenden Christoph Schneegans <Christoph@Schneegans.de> - 2015-12-07 15:03 +0100
csiph-web