for (int i=0; i<2; i++) {
java.io.StringReader inString = new StringReader(MsgHeader);
DOMParser parser = new DOMParser();
InputSource in = new InputSource(inString);
parser.setFeature("http://xml.org/sax/features/namespaces", true);
parser.parse(in);
}
It works. However, I do not want to create StringReader and InputSource in every iteration.
If I put them outside the loop, I got "org.xml.sax.SAXParseException: The root element is required in a well-formed document" after the first parsing.
I added inString.reset() after the first parsing, and got the
following error java.io.IOException: Stream closed
at java.io.StringReader.ensureOpen(Unknown
Source)
at java.io.StringReader.reset(Unknown
Source)
at FileParser.execute(FileParser.java:352)
at FileParser.main(FileParser.java:388)
Does any one know how the stream got closed ? Is it possible to reopen it without create a new StringReader?
Komal.
