日期:2014-05-20  浏览次数:20754 次

linux 下读取中文文件名为乱码
正在开发的WEB系统是部署在RED HEAD 。
RH版本信息:
LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5 (Tikanga)
Release: 5
Codename: Tikanga
-------------------------------
locale 信息
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=
---------------------------------
因为程序目录有若干文件要读出来显示在页面上,文件名为中文名
我使用File.list()方法得到了文件名列表,可是显示出来的都是乱码。
new String(filename.getBytes("utf-8"),"GBK");
new String(filename.getBytes("iso-8859-1"),"GBK");
都不起作用,
另外,使用 ls 命令查看的时候,是乱码,使用 ls --show-control-chars 命令就能显示中文名(控制台)

各位有好的解决方案么?

------解决方案--------------------
如果不行,换这个!
Java code
new String(filename.getBytes(),"UTF-8");

------解决方案--------------------
file.encoding是UTF-8
那filename.encoding呢?