@、使用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