获取assets下properties文件内容

如果我们在我们开发中需要一些固定的配置,propertoise文件可以很容易满足我们的需求。

下面简单的几个步骤,让我们来简单的使用它:

1.在assets文件下创建

accountsdk.properties文件,内容如下:
UploadProvider.authorities = com.bbk.bfcupload.bfcuploadtestdemo
2.获取内容
 private static final String properties_file = "/assets/accountsdk.properties";
 InputStream ins = SomClass.class.getResourceAsStream(properties_file);//someClass是某一个类
 Properties prop = new Properties();
  prop.load(ins);
  String str = prop.getProperty("PersonalInfoProvider.authorities");//文件里面配置的名

  此时str的内容就是:
com.bbk.bfcupload.bfcuploadtestdemo

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章