1
output = new ZipArchiveOutputStream(response.getOutputStream());

output.setCreateUnicodeExtraFields(UnicodeExtraFieldPolicy.ALWAYS);
response.setContentType(APPLICATION_ZIP);

output.putArchiveEntry(new ZipArchiveEntry("日本語.txt");
// write file to output stream
output.closeArchiveEntry();

But after download the file names are garbled, while the files(file content) are ok.

If I write the zip file to filesystem using FileOutputStream the filenames are retained as is, but only when streaming the file using ServletOutputStream the filename inside the Zip file are garbled.

Is there a workaround for this? Do I need to set character encoding for the output stream too, not sure if that actually is there?

Arjun Ramesh
  • 189
  • 1
  • 12
  • The issue is with ServletOutputStream garbling the file names in the Zip file (ZipEntry). The same works ok if I write the zip file to filesystem using FileOutputStream. Answers in the question only talk about the differences between the formats and not about the Outpustreams – Arjun Ramesh Oct 26 '17 at 22:50

0 Answers0