配置檔案的書寫

2021-08-30 14:26:12 字數 999 閱讀 3742

最近研究了一下配置檔案的讀取,經過不斷的失敗後終於成功了。

下在就把三種方式貼出來。方便大家的學習。

1.1 讀檔案的部分(全部讀出,setting_file為檔名稱,檔案儲存在其快取目錄下。)

string data = null;

fileinputstream stream = null;

try catch (filenotfoundexception e) catch (ioexception e) finally catch (ioexception e) catch (filenotfoundexception e) catch (ioexception e) finally catch (ioexception e) catch (filenotfoundexception e) catch (ioexception e) finally catch (ioexception e) catch (filenotfoundexception e) catch (ioexception e) finally catch (ioexception e) {

3.1 讀檔案的部分(部分讀出,檔名稱就是類名,檔案儲存在其快取目錄下。)

3.2 寫檔案的部分

sharedpreferences settings = null;

settings = getpreferences(activity.mode_private);

sharedpreferences.editor editor = settings.edit();

editor.putstring("server_url", "");

editor.commit();

nginx 主配置檔案的書寫

定義nginx執行的使用者和組 user www www nginx程序數,官方建議是與cpu總核心數一樣,8核心填寫8或者填寫auto。worker processes auto 全域性錯誤日誌定義型別 debug info notice warn error crit error log hom...

log4j配置檔案的書寫

顯示級別 logger debug threshold warn 輸出最低層次。immediateflush true 預設值是 true,訊息都會被立即輸出。target system.err 預設情況下是 system.out,指定輸出控制台 threshold warn 輸出最低層次。imme...

springboot中配置檔案的書寫與讀取方式

以下分別展示了普通屬性鍵值對,陣列,物件的幾種寫法 兩種語法的說明 properties沒有層級關係使用 賦值 yml有層級關係使用 賦值 注意冒號後面有空格 component public class mytest private string name 直接像上面一樣,寫在變數的上面,是讀取不...