Skip to main content

XML encoding

No replies
Joined: 2008-09-10


I have to load an XML file via

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.