URL url = Thread.currentThread().getContextClassLoader().getResource("");
String path = url.getPath();
System.out.print(path);                

打印输出:

windows中java读目录空格变成%20 处理方法

path = URLDecoder.decode(path, "utf-8");
System.out.print(path);

打印输出:

windows中java读目录空格变成%20 处理方法

 

总结:java读目录空格变成%20 处理方法,使用utf-8字符编码进行转码则可以获取正确值。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2021-09-28
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-27
  • 2022-01-15
  • 2022-02-13
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案