Hi Team,
I am using org.codehaus.stax2.XMLStreamReader2 to read from a xml file. While reading it i need two different objects of XMLStreamReader2 for same xml file.
When i use CloseCompletely() method as mentioned in
http://fasterxml.github.io/stax2-api/javadoc/3.1.4/org/codehaus/stax2/XMLStreamReader2.html#closeCompletely() link, It says this method also does close the
underlying input source.I want to ask here, if i use two reader objects from same input source, calling closeCompletely() method affect other reader object, or it will close refferences for reader1 object only?PFB the sample code for the same:
XMLStreamReader2 reader1 = (XMLStreamReader2) inputFactory.createXMLStreamReader(new ByteArrayInputStream(byteArrayFromInputStream));
reader1.next();
XMLStreamReader2 reader2 = (XMLStreamReader2) inputFactory.createXMLStreamReader(new ByteArrayInputStream(byteArrayFromInputStream));
reader2.next();
//here do some processing and close the reader2
reader2.closeCompletely();
//When i call closeCompletely() method at this point , the cursor of reader1 object is at some xml element tag. Will this closeCompletely() closes all references of inputsources? so that when i do reader1.next() will it work without any error?
//If yes what is the best way to close one reader object safely without affecting other if both the reader objects are from same inputsource?.
reader1.next(); // will this work properly and i can continue for reading next elements?
Thanks,
Snehal