android读取properties配置文件
来源:互联网 发布:淘宝网购物女装衬衣 编辑:程序博客网 时间:2024/05/18 05:26
因为一些配置信息,多处用到的。且以后可能变更的,我想写个.prorperties配置文件给管理起来。
我把配置文件放在了assets文件夹下
appConfig.properties:
serverUrl=http://192.168.1.155/ap
操作的工具类:
MyProperUtil.java:
package cn.com.smartcost.offer.util;import java.io.InputStream;import java.util.Properties;import android.content.Context;/** * 读取properties配置文件 * * @date 2014-1-15 10:06:38 * * */public class MyProperUtil {private static Properties urlProps; public static Properties getProperties(Context c){Properties props = new Properties();try {//方法一:通过activity中的context攻取setting.properties的FileInputStreamInputStream in = c.getAssets().open("appConfig.properties");//方法二:通过class获取setting.properties的FileInputStream//InputStream in = PropertiesUtill.class.getResourceAsStream("/assets/ setting.properties ")); props.load(in);} catch (Exception e1) {// TODO Auto-generated catch blocke1.printStackTrace();}urlProps = props;System.out.println(urlProps.getProperty("serverUrl")); return urlProps;}}
使用:
properties = MyProperUtil.getProperties(getApplicationContext());url = properties.getProperty("serverUrl");Log.i("URL", url);
4 0
- Android 读取Properties配置文件
- android读取properties配置文件
- android读取properties配置文件
- android读取properties配置文件
- java 读取properties配置文件
- Java读取properties配置文件
- 读取properties配置文件
- java读取properties配置文件
- java 读取配置文件properties
- 读取.properties配置文件
- java 读取*.properties配置文件
- Java读取properties配置文件
- java 读取配置文件(properties)
- java读取 .properties配置文件
- Properties 读取配置文件
- java读取properties配置文件
- Properties配置文件读取
- spring 读取properties配置文件
- Referenced file contains errors (http://struts.apache.org/dtds/struts-2.3.dtd)
- Oracle日期函数
- <摘录>TS,PS,PES包格式
- I/O 获取指定目录下的指定文件和目录
- ContentProvider 那点事儿
- android读取properties配置文件
- $.fn.extend的讲解, jQuery插件开发的两种方法
- hdu 1306 String Matching
- 具有中国特色的docker折腾记(上)
- IE XDomainRequest 学习笔记
- 3.求子数组的最大和(数组)
- ORACLE(SQL)使用小记
- HDU 1098
- linux命令ps aux|grep xxx详解