国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

J2SE API讀取Properties文件六種方法

2019-11-18 11:37:18
字體:
來源:轉載
供稿:網友

使用J2SEAPI讀取PRoperties文件的六種方法

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

示例:InputStreamin=lnewBufferedInputStream(newFileInputStream(name));

Propertiesp=newProperties();

p.load(in);

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

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

3。使用java.util.PropertyResourceBundle類的構造函數

示例:InputStreamin=newBufferedInputStream(newFileInputStream(name));

ResourceBundlerb=newPropertyResourceBundle(in);

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

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

Propertiesp=newProperties();

p.load(in);

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

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

Propertiesp=newProperties();

p.load(in);

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

示例:InputStreamin=ClassLoader.getSystemResourceAsStream(name);

Propertiesp=newProperties();

p.load(in);

補充

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

示例:InputStreamin=context.getResourceAsStream(path);

Propertiesp=newProperties();

p.load(in);



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沁源县| 卫辉市| 融水| 古浪县| 正阳县| 台中县| 藁城市| 祁门县| 宝坻区| 定安县| 荃湾区| 丰原市| 鄂州市| 通河县| 阜新| 施甸县| 府谷县| 五原县| 建始县| 屯门区| 同德县| 新化县| 峨眉山市| 乌兰县| 刚察县| 连山| 琼海市| 临朐县| 大城县| 云龙县| 松潘县| 上杭县| 成武县| 报价| 全州县| 嘉义县| 叙永县| 南江县| 博罗县| 潍坊市| 芜湖市|