可能是编码问题,大家帮忙看一下

daemon_boy 2007-10-22 09:42:23
在[path.properties]文件中,有个下面的对应关系

[path_formatxml=D:/Eclipse32/workspace/ソースTH/資料_xmlFileFormat/]

上面,红色部分的是日文(就是在日文输入法下,输入的)
我利用[Properties]这个类,来读取[path_formatxml]的信息,
Properties prop = new Properties();
FileInputStream fis;

try {
fis = new FileInputStream(propFilePath);
prop.load(fis);
fis.close();
} catch (FileNotFoundException e) {
throw e;
} catch (IOException e) {
throw e;
}
String path_formatxml = Utils.convertString(prop.getProperty("path_formatxml"));

其中,Utils.convertString()方法:
public static String convertString(String str)
throws UnsupportedEncodingException {

byte[] bytes = str.getBytes("iso-8859-1");
str = new String(bytes, System.getProperty("file.encoding"));


return str;

}


返回的内容是[D:/Eclipse32/workspace/メ[スTH/資料_xmlFileFormat/]
好像是,编码出了问题,我的系统是日文xp,开发环境全是日文的


日文的汉子如[資料]返回正常,但是日文的假名如[ソース]返回不正常
希望,高手,给指点一下哦



...全文
57 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
daemon_boy 2007-10-22
  • 打赏
  • 举报
回复
试了,不好用
fsolsh 2007-10-22
  • 打赏
  • 举报
回复
可能是因为编码的字符集不对
iso-8859-1 换成 UTF-8 试试
  • 打赏
  • 举报
回复
使用 JDK 的 native2ascii 转一下。

native2ascii <旧properties文件> <新properties文件>

再试试看,使用新文件,将旧文件保留着,便于日后的更改。

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧