java -- 路径中包含空格怎么处理

@、使用toURI()方法

String rootPath = this.getClass().getClassLoader().getResource(".").toURI().getPath();

原文:https://www.cnblogs.com/tv151579/p/6220443.html

@、使用URLDecoder.decode方法

String rootPath = this.getClass().getClassLoader().getResource(".").getPath();

这中方式获取到的路径,其中的空格被转换成%20,可通过rootPath = URLDecoder.decode(rootPath ,"utf-8");进行转换。

原文:https://blog.csdn.net/aa__aa1122/article/details/50409342

原文地址:https://www.cnblogs.com/yarightok/p/10691652.html