欧美国产另类久热|951超碰伊人久久|伊人影视久久久久|色婷婷亚洲小电影|色东京热69XX|婷婷玖玖深爱网|加勒比东京热网站|无码A级毛片在线观看|一级a毛一级a看|中文字幕人妻欧美

Java 加載Properties文件的六種方式
來源:易賢網(wǎng) 閱讀:938 次 日期:2015-04-10 14:46:41
溫馨提示:易賢網(wǎng)小編為您整理了“Java 加載Properties文件的六種方式”,方便廣大網(wǎng)友查閱!

1。使用java.util.Properties類的load()方法

示例: InputStream in = lnew BufferedInputStream(new FileInputStream(name));

Properties p = new Properties();

p.load(in);

2。使用java.util.ResourceBundle類的getBundle()方法

示例: ResourceBundle rb = ResourceBundle.getBundle(name, Locale.getDefault());

3。使用java.util.PropertyResourceBundle類的構(gòu)造函數(shù)

示例: InputStream in = new BufferedInputStream(new FileInputStream(name));

ResourceBundle rb = new PropertyResourceBundle(in);

4。使用class變量的getResourceAsStream()方法

示例: InputStream in = JProperties.class.getResourceAsStream(name);

Properties p = new Properties();

p.load(in);

5。使用class.getClassLoader()所得到的java.lang.ClassLoader的getResourceAsStream()方法

示例: InputStream in = JProperties.class.getClassLoader().getResourceAsStream(name);

Properties p = new Properties();

p.load(in);

6。使用java.lang.ClassLoader類的getSystemResourceAsStream()靜態(tài)方法

示例: InputStream in = ClassLoader.getSystemResourceAsStream(name);

Properties p = new Properties();

p.load(in);

補(bǔ)充

Servlet中可以使用javax.servlet.ServletContext的getResourceAsStream()方法

示例:InputStream in = context.getResourceAsStream(path);

Properties p = new Properties();

p.load(in);

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:Java 加載Properties文件的六種方式
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點

版權(quán)所有:易賢網(wǎng)