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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM