我想读取位于assets/目录中的xml文件。 我已经尝试过这个解决方案(在网上找到的)
InputStream istr = context.getAssets().open("stanza.xml");
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xrp = factory.newPullParser();
xrp.setInput(istr, "UTF-8");
但返回 FileNotFoundException,但文件存在。
请帮助我理解。
最佳答案
如果您的代码属于您的 Activity ,您可以简单地编写:
InputStream istr = getResources().getAssets().open("stanza.xml");
关于java - 读取 Assets Xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11230029/