パスワード付きZIPファイルを解凍する。 日本語パスワードに対応。しかし日本語ファイルには未対応。
// password-protected zip file I need to read
FileInputStream fis = new FileInputStream("C:\\temp\\passzip.zip");
// wrap it in the decrypt stream
ZipDecryptInputStream zdis = new ZipDecryptInputStream(fis, "日本語", "MS932");
// wrap the decrypt stream by the ZIP input stream
ZipInputStream zis = new ZipInputStream(zdis);
// read all the zip entries and save them as files
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
FileOutputStream fos = new FileOutputStream(ze.getName());
int b;
while ((b = zis.read()) != -1) {
fos.write(b);
}
fos.close();
zis.closeEntry();
}
zis.close();
このクラスを実装するにあたり、色々なサイトを参考にさせて頂きました。この場を借りて感謝します。