I am trying to parse an XML file using Java.
The XML file size is 256 kb only. I am using a DOM parser to parse the XML file. How can I parse the large XML file content?
Here's the method that parses the file content:
public Document parse_a_string(StringBuffer decodedFile) {
Document doc1 = null;
try {
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder db = factory.newDocumentBuilder();
InputSource inStream = new InputSource();
// problem here
inStream.setCharacterStream(new StringReader(decodedFile.toString()));
doc1 = db.parse(inStream);
} catch (Exception e) {
}
return doc1;
}
The file content is in the StringBuffer
reference object, decodedFile
, but when I set it to StringReader
it accept only string.