android读取plist文件
16lz
2021-12-04
阅读更多 ios的配置文件是写在.plist里。
那么,如何从android读取.plist文件内容呢?
1.需要导入dd-plist.jar
2.读取.plist文件
config.plist
逻辑方法
XmlUtil中的方法
那么,如何从android读取.plist文件内容呢?
1.需要导入dd-plist.jar
2.读取.plist文件
config.plist
<?xml version="1.0" encoding="UTF-8"?>version 1 net http timeout 30 URL http://xxx.xxx.xxx.xxx certifyUser URL http://xxx.xxx.xxx.xxx/certifyUser encoding utf-8
逻辑方法
URL url = null;InputStream in = null;in = XmlUtil.getFileInputStream( "config/config.plist", context );NSDictionary configSetting = (NSDictionary) PropertyListParser.parse( in );NSDictionary configNet = (NSDictionary) configSetting.objectForKey( "net" );NSDictionary configHttp = (NSDictionary) configNet.objectForKey( "http" );String strUrl = configHttp.objectForKey( "URL" ).toString();url = new URL( strUrl );
XmlUtil中的方法
public static InputStream getFileInputStream( String fileName, Context context ) { AssetManager am = context.getResources().getAssets(); InputStream in = null; try { in = am.open( fileName ); } catch ( IOException e ) { // TODO Auto-generated catch block e.printStackTrace(); } return in;}
更多相关文章
- 浅谈Java中Collections.sort对List排序的两种方法
- NPM 和webpack 的基础使用
- Python list sort方法的具体使用
- 【阿里云镜像】使用阿里巴巴DNS镜像源——DNS配置教程
- python list.sort()根据多个关键字排序的方法实现
- 在Android中把SQLite的数据库文件存储在SD卡中【转】
- android studio快捷键 for mac
- Android用HTTP下载报错“android.os.StrictMode$AndroidBlockGua
- android常见技巧---Android按返回键退出程序但不销毁