我正在尝试使用 BeanIO 读取/写入 Android 应用程序中的 csv 文件。当我尝试创建 的实例时StreamFactory
,出现以下错误:
03-02 08:52:19.076: E/AndroidRuntime(9305): FATAL EXCEPTION: main
03-02 08:52:19.076: E/AndroidRuntime(9305): org.beanio.BeanIOException: Failed to load stream factory implementation class 'org.beanio.internal.DefaultStreamFactory'
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.StreamFactory.newInstance(StreamFactory.java:353)
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.StreamFactory.newInstance(StreamFactory.java:304)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.catfoodcalc.io.CatFoodFileUtil.getBeanReader(CatFoodFileUtil.java:20)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.catfoodcalc.io.CatFoodFileUtil.retrieveSavedCatFoodList(CatFoodFileUtil.java:42)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.catfoodcalc.MainActivity.saveCatFood(MainActivity.java:176)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.catfoodcalc.MainActivity.access$0(MainActivity.java:164)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.catfoodcalc.MainActivity$1.onClick(MainActivity.java:194)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:174)
03-02 08:52:19.076: E/AndroidRuntime(9305): at android.os.Handler.dispatchMessage(Handler.java:99)
03-02 08:52:19.076: E/AndroidRuntime(9305): at android.os.Looper.loop(Looper.java:158)
03-02 08:52:19.076: E/AndroidRuntime(9305): at android.app.ActivityThread.main(ActivityThread.java:5789)
03-02 08:52:19.076: E/AndroidRuntime(9305): at java.lang.reflect.Method.invokeNative(Native Method)
03-02 08:52:19.076: E/AndroidRuntime(9305): at java.lang.reflect.Method.invoke(Method.java:525)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
03-02 08:52:19.076: E/AndroidRuntime(9305): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:843)
03-02 08:52:19.076: E/AndroidRuntime(9305): at dalvik.system.NativeStart.main(Native Method)
03-02 08:52:19.076: E/AndroidRuntime(9305): Caused by: org.beanio.BeanIOException: Unable to validate using XSD: JAXP provider [org.apache.harmony.xml.parsers.DocumentBuilderFactoryImpl@41bc27f8] does not support XML Schema.
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.internal.config.xml.XmlMappingReader.createDocumentBuilderFactory(XmlMappingReader.java:125)
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.internal.config.xml.XmlMappingReader.<init>(XmlMappingReader.java:50)
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.internal.config.xml.XmlConfigurationLoader.<init>(XmlConfigurationLoader.java:34)
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.internal.compiler.StreamCompiler.<init>(StreamCompiler.java:48)
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.internal.DefaultStreamFactory.init(DefaultStreamFactory.java:48)
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.StreamFactory.newInstance(StreamFactory.java:349)
03-02 08:52:19.076: E/AndroidRuntime(9305): ... 15 more
03-02 08:52:19.076: E/AndroidRuntime(9305): Caused by: java.lang.IllegalArgumentException: http://java.sun.com/xml/jaxp/properties/schemaLanguage
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.apache.harmony.xml.parsers.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:86)
03-02 08:52:19.076: E/AndroidRuntime(9305): at org.beanio.internal.config.xml.XmlMappingReader.createDocumentBuilderFactory(XmlMappingReader.java:119)
03-02 08:52:19.076: E/AndroidRuntime(9305): ... 20 more
发生这种情况的代码如下所示:
private static BeanReader getBeanReader() {
StreamFactory factory = StreamFactory.newInstance(); //This is where the above exception is thrown
factory.load(MAPPING_FILE);
File inputFile = new File("myFile");
return factory.createReader("myBeanIOStream", inputFile);
}
我对 Android 和 BeanIO 开发都是新手,所以如果我在这里遗漏了一些明显的东西,我深表歉意。我已经做了相当多的谷歌搜索,找不到任何有类似问题的人。BeanIO 甚至与 Android 兼容吗?我应该在DocumentBuilderFactory
某处指定不同的实现吗?
非常感谢解决此错误的任何帮助!