0

Modified(lastModified)属性を処理できました。つまり、アーカイブ内でファイルのModified属性を保持できました。
サンプルは次のとおりです。

ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream( new FileOutputStream(outFilename)));
File f = new File(filename);
long longLastMod = f.lastModified();
FileInputStream in = new FileInputStream(filename);
// Add ZIP entry to output stream.
ZipEntry ze = new ZipEntry(filename);
ze.setTime(longLastMod);  // the "magic" to store the Modified date/time of the file
out.putNextEntry( ze );
// Transfer bytes from the file to the ZIP file
int len;
while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
}
out.closeEntry();
in.close();
out.close();

これで、出力ZipファイルはModified属性を保持しますが、CreatedまたはAccessed属性は保持しません。これを達成する方法はありますか?

4

1 に答える 1

0

これを達成する方法はありますか?

いいえ、それは不可能です。簡単に言うと、zipディレクトリは属性をサポートしていません。

ただし、できることは、setExtra(byte[])必要な情報を使用して保存することです。残念ながら、属性を保持するにはカスタムエクストラクタが必要です。

お役に立てれば!

于 2011-02-28T19:21:46.163 に答える