本篇文章為大家展示了JAVA中怎么實(shí)現(xiàn)一個(gè)讀取配置文件類(lèi),內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
創(chuàng)新互聯(lián)憑借在網(wǎng)站建設(shè)、網(wǎng)站推廣領(lǐng)域領(lǐng)先的技術(shù)能力和多年的行業(yè)經(jīng)驗(yàn),為客戶(hù)提供超值的營(yíng)銷(xiāo)型網(wǎng)站建設(shè)服務(wù),我們始終認(rèn)為:好的營(yíng)銷(xiāo)型網(wǎng)站就是好的業(yè)務(wù)員。我們已成功為企業(yè)單位、個(gè)人等客戶(hù)提供了成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)服務(wù),以良好的商業(yè)信譽(yù),完善的服務(wù)及深厚的技術(shù)力量處于同行領(lǐng)先地位。
1. 配置文件 myconf.properties
url=www.baidu.com
2. 類(lèi)文件 MyProperties.class
public class MyConf { public static Properties properties = new Properties(); public static String url= getPropertieVal("url"); public static String getPropertieVal(String propertype){ if(properties==null || properties.size()==0) readProperties(); return properties.getProperty(propertype); } public static void readProperties() { try { properties.load(MyConf.class.getResourceAsStream("/myconf.properties")); }catch(FileNotFoundException e){ System.out.println("Error read"); } catch (IOException e) { e.printStackTrace(); } } }
3. 調(diào)用
Class Test { public static void main(String[] args) { System.out.println(MyConf.url); } }
上述內(nèi)容就是JAVA中怎么實(shí)現(xiàn)一個(gè)讀取配置文件類(lèi),你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
本文題目:JAVA中怎么實(shí)現(xiàn)一個(gè)讀取配置文件類(lèi)
文章網(wǎng)址:http://muchs.cn/article26/gppjjg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、網(wǎng)站策劃、外貿(mào)建站、網(wǎng)站維護(hù)、網(wǎng)頁(yè)設(shè)計(jì)公司、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
全網(wǎng)營(yíng)銷(xiāo)推廣知識(shí)