這裡我將配置檔案放在src目錄下了,下面放的都是實驗過的**:
1、獲取到流檔案
fileinputstream is = new fileinputstream("src/jdbc.properties");
//2、載入流檔案
properties properties = new
properties();
properties.load(is);
//3、獲取到配置檔案資訊
string driver = properties.getproperty("driver");
string url = properties.getproperty("url");
string name = properties.getproperty("name");
string passwd = properties.getproperty("passwd");
//1、獲取到流檔案inputstream is = thread.currentthread().getcontextclassloader().getresourceasstream("jdbc.properties"
);//2、載入流檔案
properties properties = newproperties();
properties.load(is);
//3、獲取到配置檔案資訊
string driver = properties.getproperty("driver");
string url = properties.getproperty("url");
string name = properties.getproperty("name");
string passwd = properties.getproperty("passwd");
//1、獲取到流檔案resourcebundle bundle = resourcebundle.getbundle("jdbc"
);//2、獲取到配置檔案資訊
string driver = bundle.getstring("driver");
string url = bundle.getstring("url");
string name = bundle.getstring("name");
string passwd = bundle.getstring("passwd");
mybatis讀取properties檔案內容
今天在mybatis中想讀取檔案內容,一開始是建立的xml檔案,發現必須要表頭,不然就是 完全不適用,然後突然靈光一現,可以建立properties檔案,讀取檔案,通過鍵值對獲取內容。properties proper new properties proper.load this.getclass...
java sdk讀取properties檔案
獲得properties檔案中key為classname的值 resourcebundle bundle resourcebundle.getbundle data 通過getbundle獲得src下properties檔案 檔名為data.properties 獲得值 string classna...
python讀取properties配置檔案並解析
ld.properties 配置資訊 database.type argo database.name dd database.ip 10.12.15.225 database.port 10000 database.username user database.password passwd pr...