本篇文章給大家分享的是有關(guān)properties配置文件怎么利用java進(jìn)行讀取,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

具體如下:
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
public class loadConf {
private Properties prop = new Properties();
private void loadconf() throws FileNotFoundException, IOException {
String path = "com/jlc/util/user.properties";
prop.load(loadConf.class.getClassLoader() .getResourceAsStream(path));
}
public loadConf() throws FileNotFoundException, IOException {
loadconf();
}
public boolean chkProperty(String _key) {
return prop.containsKey(_key);
}
public String getProperty(String _key) {
return prop.getProperty(_key);
}
public static void main(String[] args) throws FileNotFoundException, IOException {
loadConf mycnf = new loadConf();
System.out.println(mycnf.chkProperty("address"));
System.out.println(mycnf.getProperty("poart"));
}
}
網(wǎng)站題目:properties配置文件怎么利用java進(jìn)行讀取-創(chuàng)新互聯(lián)
網(wǎng)頁路徑:http://chinadenli.net/article24/ceddje.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站維護(hù)、外貿(mào)建站、微信公眾號(hào)、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容