// 獲取classpath的絕對值路徑,有中文需要解碼路徑,不然輸出的是亂碼的
private static String basePath;
static {
try {
basePath = URLDecoder.decode(Thread.currentThread().getContextClassLoader().getResource("").getPath(),"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
參考鏈接:https://blog.csdn.net/yuhaiqiang_123/article/details/51288456