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