Java讀寫配置檔案properties

2021-07-28 20:58:22 字數 662 閱讀 4692

1.新建乙個test.properties檔案,裡面的值是pageno=1 

3.後來發現properties檔案一般只是用來做常量的讀入,而變數的寫入開啟檔案後根本不會變化,後來又改用txt檔案來實現讀寫。

string filepath=system.getproperty("user.dir");  //得到當前路徑

* 根據主鍵key讀取主鍵的值value  

* @param filepath 屬性檔案路徑  

* @param key 鍵名  

*/ public static string readvalue() catch (exception e)   

}   

/**  

* 更新(或插入)一對properties資訊(主鍵及其鍵值)  

* 如果該主鍵已經存在,更新該主鍵的值;  

* 如果該主鍵不存在,則外掛程式一對鍵值。  

* @param keyname 鍵名  

* @param keyvalue 鍵值  

*/   

public static void writeproperties(string keyname,int keyvalue) catch (ioexception e)   

}  

讀寫配置檔案

windows作業系統專門為此提供了6個api函式來對配置設定檔案進行讀 寫 getprivateprofileint 從私有初始化檔案獲取整型數值 getprivateprofilestring 從私有初始化檔案獲取字串型值 getprofileint 從win.ini 獲取整數值 getprof...

讀寫配置檔案

procedure curstepchanged curstep tsetupstep varsetupname string inipath string begin case curstep of ssinstall 複製檔案前 begin end sspostinstall 完成複製 begi...

讀寫配置檔案

寫配置檔案 include include include include using std cout using std endl int main int nlen strlen d myinifile.ini 16 nlen strlen lppath 0 strcpy s lppath,s...