檔案絕對路徑獲取

2021-08-31 08:33:57 字數 327 閱讀 4194

yourclass.class.getclassloader().getresource("threadpoolconfig.xml").getpath();

通過上述方法獲取到的一般是指定檔案的絕對路徑

並且該檔案必須存放在src目錄下

******************************==

存在的問題:

如果絕對路徑中存在空格, getpath取到的值是經過urlencoder之後的,如果基於此路徑位元組使用fileinputstream進行載入的話會報找不到檔案

需要 urldecoder.decode進行處理,替換掉對於特殊字元的轉義

jeecms獲取絕對路徑

在jeecms後台管理做乙個附件上傳到伺服器上,然後讀取改上傳檔案,半天獲取不到路徑,後來發現有定義好的絕對路徑獲取方法 最好將檔案上傳到u資料夾底下 string path u cms www 201807 26111223imd7.xls file file new file realpathr...

MFC獲取檔案的絕對路徑

i.需求1.獲取當前檔案的絕對路徑 firstname用於存放檔案的絕對路徑位址 define maxsize 1024 char firstname maxsize memset firstname,0x00 maxsize 1.獲取檔案的絕對路徑 getmodulefilename afxget...

python獲取檔案的絕對路徑

檔案目錄結構如下 第一種方法 os.path.abspath file import os def load file 獲取當前檔案路徑 current path os.path.abspath file 獲取當前檔案的父目錄 father path os.path.abspath os.path....