ZipInputStream(InputStream, Charset) decodes ZipEntry file name falsely

后端 未结 1 1021
清歌不尽
清歌不尽 2021-01-13 10:02

Java 7 is supposed to fix an old problem with unpacking zip archives with character sets other than UTF-8. This can be achieved by constructor ZipInputStream(InputStre

相关标签:
1条回答
  • 2021-01-13 10:56

    OMG, I played around for two or so hours, but just five minutes after I finally posted the question here, I bumped into the answer: My zip file was not encoded with ISO-8859-1, but with Cp437. So the constructor call should be:

    zipStream = new ZipInputStream(
        new BufferedInputStream(new FileInputStream(archiveFile), BUFFER_SIZE),
        Charset.forName("Cp437")
    );
    

    Now it works like a charm. Sorry for bothering you anyway. I hope this helps someone else facing similar problems.

    0 讨论(0)
提交回复
热议问题