我得到这行代码的 IOException 。
Response oresponse = orequest.send();
**This above Response object contains Xml data** :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<person>
<first-name>xyz</first-name>
<last-name>abc</last-name>
<api-standard-profile-request>
<url>http:[Removed]</url>
<headers total="1">
<http-header>
<name>[removed]</name>
<value>[removed]</value>
</http-header>
</headers>
</api-standard-profile-request>
</person>
我的解析代码如下。
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(oresponse.getStream());
我得到了最后一行的 IOException ,即dBuilder.parse(oresponse.getStream())
。表示在解析期间。我如何解析这个xml。它给了我:
java.io.IOException: stream is closed.
at sun.net.www.http.ChunkedInputStream.ensureOpen(Unknown Source)
at sun.net.www.http.ChunkedInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)