File names with Japanese characters turn to garbage when written to a zip file using java.util.zip.*

后端 未结 3 1699
粉色の甜心
粉色の甜心 2021-01-20 11:00

I have a directory with a name that contains Japanese characters, and I need to use the zip utils in java.util.zip to write it to a zip file. Writing the zip file succeeds,

3条回答
  •  独厮守ぢ
    2021-01-20 11:33

    Miracles indeed happen, and Sun/Oracle did really fix the long-living bug/rfe:

    Now it's possible to [set up filename encodings upon creating][1] the zip file/stream (requires Java 7).

    [1]: http://download.java.net/jdk7/docs/api/java/util/zip/ZipOutputStream.html#ZipOutputStream(java.io.OutputStream, java.nio.charset.Charset)

提交回复
热议问题