中文乱码处理,求助

kiOm 2005-08-08 03:59:46
String path = Test.class.getProtectionDomain().getCodeSource().getLocation().getFile();
如果Test.class的上层目录有包含中文的,则path将出现乱码.
如何解决????
...全文
133 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kiOm 2005-08-10
  • 打赏
  • 举报
回复
谢了~
大河V5 2005-08-08
  • 打赏
  • 举报
回复
同上
aico 2005-08-08
  • 打赏
  • 举报
回复
这不是乱码,是Unicode编码后又进行URL编码的结果。
如想看汉字,可以这样:
String path = Test.class.getProtectionDomain().getCodeSource().getLocation().getFile();
try{
path = java.net.URLDecoder.decode(path,"UTF-8");
}catch(Exception e){}
System.out.println(path);

62,634

社区成员

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

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