您的位置:首页 > 移动开发 > Android开发

JAVA android 获取assets文件夹中的properties文件 并从中获取数据

2018-03-01 14:59 639 查看
class PropertiesUtils {
private static Properties properties = null;
private static void readProperties() {
try {
InputStream in = PropertiesUtils.class.getResourceAsStream("/assets/sdk_param_config.properties");
properties = new Properties();
properties.load(in);
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
Log.e("PropertiesUtils", "get nothing");
e.printStackTrace();
}
}

public static Properties getProperties() {
if (properties == null) {
readProperties();
}
return properties;
}
}


文件存放于主程序里



获取数据



String a = properties.getProperty("a");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  安卓SDK
相关文章推荐