android读取plist文件

阅读更多
ios的配置文件是写在.plist里。
那么,如何从android读取.plist文件内容呢?
1.需要导入dd-plist.jar
2.读取.plist文件


config.plist




	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;
}

你可能感兴趣的:(android,java,plist,dd-plist)