使用java.util.zip写入zip文件时,带有日文字符的文件名将变为垃圾。* [英] File names with Japanese characters turn to garbage when written to a zip file using java.util.zip.*

查看:265
本文介绍了使用java.util.zip写入zip文件时,带有日文字符的文件名将变为垃圾。*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名称包含日文字符的目录,我需要使用java.util.zip中的zip utils将其写入zip文件。编写zip文件成功,但是当我用Windows的内置压缩文件实用程序或7-Zip打开生成的zip文件时,名称中带有日文字符的目录显示为一堆垃圾字符。我的系统上安装了日语/东亚语言包 - 我可以创建日语名称的目录,所以这不是问题。

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, but when I open the resulting zip file with either Windows' built-in compressed file utility or 7-Zip, the directory with Japanese characters in the name appears as a bunch of garbage characters. I do have the Japanese/East Asian language pack installed on my system -- I can create directories with Japanese names, so that isn't the issue.

有趣的是,如果我编写了一个单独的脚本来使用java.util.zip读取生成的zip文件,目录名称是正确的,我可以将zip的内容提取到具有日文字符的适当命名的目录中。但我不能使用我尝试过的商业拉链工具,这无疑是我们的客户想要做的。

Interestingly, if I write a separate script to read the resulting zip file using java.util.zip, the directory name is correct, and I can extract the contents of the zip into appropriately named directories, with Japanese characters. But I can't do this using the commercial zip tools that I've tried, which is undoubtedly what our customers will want to do.

关于导致什么的任何想法这个问题,以及我如何解决它?

Any ideas about what is causing this problem, and how I can work around it?

我知道这个bug ,但我仍然需要针对这种情况的解决方法。

I know about this bug, but I still need a workaround for this case.

推荐答案

如果java.util.zip仍然表现为< a href =http://www.velocityreviews.com/forums/t147286-java-util-zip-not-handling-unicode-filenames.html\"rel =nofollow noreferrer>这篇文章描述了,我我不确定它是否可能(使用内置类)。我已经看过之前提到的 Chilkat的Java Zip库作为一种方法工作,但从未使用过它。

If java.util.zip still behaves as this post describes, I'm not sure if it is possible (with the built-in classes). I have seen Chilkat's Java Zip library mentioned before as a way to get this to work, but have never used it.

这篇关于使用java.util.zip写入zip文件时,带有日文字符的文件名将变为垃圾。*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆