バイナリデータのグループ(データベースから返された結果セット)を1つのファイルに圧縮しようとしています。ウェブアプリケーションからダウンロードできます。Javaでバイナリデータを圧縮する
ファイルパス:次のコードは、WinRarのを使ってダウンロードしたzipファイルを解凍中に問題が、私はエラー以下を取得していることをHttpServletResponse
String outFilename = "outfile.zip"; response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment; filename= " + outFilename); OutputStream os = response.getOutputStream(); ZipOutputStream out = new ZipOutputStream(os); for (int i = 0; i < cardFileList.size(); i++) { CardFile cardFile = cardFileList.get(i); out.putNextEntry(new ZipEntry(cardFile.getBinaryFileName())); out.write(cardFile.getBinaryFile(), 0, cardFile.getBinaryFile().length); out.closeEntry(); } // Complete the ZIP file out.flush(); out.close(); os.close();
にzipファイルを結果セットを圧縮して書き込むために使用されますかマルチパートまたは破損したZIPアーカイブ
誰かが間違っていると指摘できますか?どんな助けもありがとう。
[編集]私はresponse.setContentType("application/zip");
を試しましたが、同じ結果です。