Skip to main content

XML encoding

No replies
dkredd
Offline
Joined: 2008-09-10
Points: 0

Hi,

I have to load an XML file via http://xyz.com/aaa.xml

1) I retrieve the content via:

InputStream is = method.getResponseBodyAsStream();
DocumentBuilder db = factory.newDocumentBuilder();
Document doc = db.parse(is);

I do not see any code samples that are explicitly closing the input stream after the parse.Do we have to close it in finally along with method.releaseConnection?

2) The XML is encoded in UTF-8, Think HttpClient defaults to ISO. How do we set it to read UTF-8.

Thanks!