我正在尝试读取这样的Xml文件。
String soapResponse = readFile();
System.out.println(soapResponse);
//TMP END
InputDataXMLParser inputParser = new InputDataXMLParser(soapResponse, database); //Exception at this line
inputParser.saveInputFiles();
} catch (Exception exception) {
exception.printStackTrace();}
我的readFile()方法
private String readFile() throws Exception{
AssetManager assetManager = activity.getAssets();
InputStream ims = assetManager.open("temp/gssoOutbound.xml");
StringBuffer fileContent = new StringBuffer("");
byte[] buffer = new byte[1024];
while (ims.read(buffer) != -1) {
fileContent.append(new String(buffer));
}
return fileContent.toString();
}
//Stack Trace
11-05 09:58:15.766: W/System.err(21020): org.xml.sax.SAXParseException: Unexpected token (position:TEXT
11-05 09:58:15.766: W/System.err(21020): URRICANE DISH D...@2:237 in java.io.StringReader@2bed3b20)
11-05 09:58:15.786: W/System.err(21020): at org.apache.harmony.xml.parsers.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:146)
11-05 09:58:15.786: W/System.err(21020): at org.col.gsso.sap.parser.InputDataXMLParser.getDomElement(InputDataXMLParser.java:510)
11-05 09:58:15.786: W/System.err(21020): at org.col.gsso.sap.parser.InputDataXMLParser.saveInputFiles(InputDataXMLParser.java:106)
11-05 09:58:15.786: W/System.err(21020): at com.gps.colpal.ToPalmDownloadAsycTask.doInBackground(ToPalmDownloadAsycTask.java:102)
11-05 09:58:15.786: W/System.err(21020): at com.gps.colpal.ToPalmDownloadAsycTask.doInBackground(ToPalmDownloadAsycTask.java:1)
11-05 09:58:15.786: W/System.err(21020): at android.os.AsyncTask$2.call(AsyncTask.java:264)
11-05 09:58:15.786: W/System.err(21020): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-05 09:58:15.786: W/System.err(21020): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-05 09:58:15.786: W/System.err(21020): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-05 09:58:15.786: W/System.err(21020): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-05 09:58:15.786: W/System.err(21020): at java.lang.Thread.run(Thread.java:856)
11-05 09:58:15.886: W/IInputConnectionWrapper(21020): finishComposingText on inactive InputConnection
但它抛出了Unexcepted异常,任何人都不知道它。